Skip to content

Commit

Permalink
Work on new release after API change #6
Browse files Browse the repository at this point in the history
- fixes #6
  • Loading branch information
mpostol committed Feb 6, 2020
1 parent 482d527 commit cd17bfe
Show file tree
Hide file tree
Showing 13 changed files with 105 additions and 187 deletions.
17 changes: 5 additions & 12 deletions CAS.CodeProtect/CAS.CodeProtect.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
<FileAlignment>4096</FileAlignment>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<ApplicationIcon>
</ApplicationIcon>
<ApplicationIcon>Logo.ico</ApplicationIcon>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>3.5</OldToolsVersion>
Expand Down Expand Up @@ -137,12 +136,6 @@
<Compile Include="LicenseDsc\AbstractLicenseData.cs" />
<Compile Include="LicenseDsc\IConstraint.cs" />
<Compile Include="LicenseDsc\ILicenseData.cs" />
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
<None Include="app.config" />
<None Include="CAS.CodeProtect.nuspec">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
Expand Down Expand Up @@ -189,10 +182,6 @@
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>AssemblyInfo.cs</LastGenOutput>
</None>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<None Include="Resources\keys.xml" />
</ItemGroup>
<ItemGroup>
Expand All @@ -201,6 +190,10 @@
<SubType>Designer</SubType>
<LastGenOutput>CAS.CodeProtect.nuspec</LastGenOutput>
</Content>
<Content Include="Logo.ico" />
<None Include="Logo64.PNG">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<Content Include="Packages\EN\package.xml">
<SubType>Designer</SubType>
</Content>
Expand Down
15 changes: 7 additions & 8 deletions CAS.CodeProtect/CAS.CodeProtect.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>CAS.CodeProtect</id>
<version>7.0.0-Alpha </version>
<version>7.0.0-Alpha</version>
<title>Licenses creation and validation library</title>
<authors>Mariusz Postol</authors>
<owners>Mariusz Postol</owners>
<projectUrl>https://github.com/mpostol/RealTime</projectUrl>
<licenseUrl>http://www.commsvr.com/DownloadCenter/ProductSoftware/LicenseAgreement.aspx</licenseUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<developmentDependency>false</developmentDependency>
<license type="expression">MIT</license>
<icon>content\Logo64.PNG</icon>
<projectUrl>https://github.com/mpostol/CodeProtect</projectUrl>
<repository type="GitHub" url="https://github.com/mpostol/CodeProtect" />
<developmentDependency>false</developmentDependency>
<description>
Helper library supporting licenses creation and validation.
</description>
Expand All @@ -23,12 +25,9 @@
<tags>CAS Software, CAS Framework, CAS Library, Licensing.</tags>
</metadata>
<files>
<file src="bin\Release\Logo64.PNG" target="content\Logo64.PNG" />
<file src="bin\Release\CAS.CodeProtect.dll" target="lib\net451\CAS.CodeProtect.dll" />
<file src="bin\Release\CAS.CodeProtect.dll.config" target="lib\net451\CAS.CodeProtect.dll.config" />
<file src="bin\Release\CAS.CodeProtect.XML" target="lib\net451\CAS.CodeProtect.XML" />
<file src="bin\Release\Microsoft.Build.Framework.dll" target="lib\net451\Microsoft.Build.Framework.dll" />
<file src="bin\Release\Microsoft.Build.Tasks.Core.dll" target="lib\net451\Microsoft.Build.Tasks.Core.dll" />
<file src="bin\Release\Microsoft.Build.Utilities.Core.dll" target="lib\net451\Microsoft.Build.Utilities.Core.dll" />
</files>
</package>

15 changes: 7 additions & 8 deletions CAS.CodeProtect/CAS.CodeProtect.tt
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id><#=Id#></id>
<version><#= CASCodeProtectProductVersion #><#= CASCodeProtectProductPreRelease #> </version>
<version><#= CASCodeProtectProductVersion #><#= CASCodeProtectProductPreRelease #></version>
<title><#= Title #></title>
<authors><#=AssemblyCompany#></authors>
<owners><#=Owner#></owners>
<projectUrl><#= repositoryUrl #></projectUrl>
<licenseUrl>http://www.commsvr.com/DownloadCenter/ProductSoftware/LicenseAgreement.aspx</licenseUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<developmentDependency>false</developmentDependency>
<license type="expression">MIT</license>
<icon>content\Logo64.PNG</icon>
<projectUrl><#=Url#></projectUrl>
<repository type="GitHub" url="<#=Url #>" />
<developmentDependency>false</developmentDependency>
<description>
<#= Description #>
</description>
Expand All @@ -25,12 +27,9 @@
<tags>CAS Software, CAS Framework, CAS Library, Licensing.</tags>
</metadata>
<files>
<file src="bin\Release\Logo64.PNG" target="content\Logo64.PNG" />
<file src="bin\Release\CAS.CodeProtect.dll" target="lib\net451\CAS.CodeProtect.dll" />
<file src="bin\Release\CAS.CodeProtect.dll.config" target="lib\net451\CAS.CodeProtect.dll.config" />
<file src="bin\Release\CAS.CodeProtect.XML" target="lib\net451\CAS.CodeProtect.XML" />
<file src="bin\Release\Microsoft.Build.Framework.dll" target="lib\net451\Microsoft.Build.Framework.dll" />
<file src="bin\Release\Microsoft.Build.Tasks.Core.dll" target="lib\net451\Microsoft.Build.Tasks.Core.dll" />
<file src="bin\Release\Microsoft.Build.Utilities.Core.dll" target="lib\net451\Microsoft.Build.Utilities.Core.dll" />
</files>
</package>

Expand Down
23 changes: 8 additions & 15 deletions CAS.CodeProtect/EnvironmentAccess/LicenseTraceSource.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
//<summary>
// Title : CAS.Lib.CodeProtect.EnvironmentAccess.LicenseTraceSource - local trace source
// System : Microsoft Visual C# .NET 2008
// $LastChangedDate$
// $Rev$
// $LastChangedBy$
// $URL$
// $Id$
//___________________________________________________________________________________
//
// Copyright (C)2011, CAS LODZ POLAND.
// TEL: +48 (42) 686 25 47
// mailto://techsupp@cas.eu
// http://www.cas.eu
//</summary>
// Copyright (C) 2020, Mariusz Postol LODZ POLAND.
//
// To be in touch join the community at GITTER: https://gitter.im/mpostol/OPC-UA-OOI
//___________________________________________________________________________________


using CAS.Lib.CodeProtect.Properties;
using System;
using System.Diagnostics;

Expand All @@ -24,6 +16,7 @@ namespace CAS.Lib.CodeProtect.EnvironmentAccess
/// </summary>
internal class LicenseTraceSource : TraceSource
{

#region internal
/// <summary>
/// <see cref="TraceEventType.Verbose"/> trace message.
Expand Down Expand Up @@ -70,7 +63,7 @@ internal static void TraceError(int id, string message)

#region private
private LicenseTraceSource()
: base(Settings.Default.TraceSourceName) { }
: base(Properties.Resources.TraceSourceName) { }
private static void PrivateTrace(TraceEventType type, int id, string message)
{
try
Expand Down
110 changes: 48 additions & 62 deletions CAS.CodeProtect/LicenseDsc/Constraints/FunctionConstraint.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
//<summary>
// Title : FunctionConstraint
// System : Microsoft Visual C# .NET 2008
// $LastChangedDate$
// $Rev$
// $LastChangedBy$
// $URL$
// $Id$
//___________________________________________________________________________________
//
// Copyright (C)2009, CAS LODZ POLAND.
// TEL: +48 (42) 686 25 47
// mailto://techsupp@cas.eu
// http://www.cas.eu
//</summary>
// Copyright (C) 2020, Mariusz Postol LODZ POLAND.
//
// To be in touch join the community at GITTER: https://gitter.im/mpostol/OPC-UA-OOI
//___________________________________________________________________________________

using CAS.Lib.CodeProtect.Properties;
using System;
using System.ComponentModel;
using System.Text;
using System.Xml;
using CAS.Lib.CodeProtect.Properties;

namespace CAS.Lib.CodeProtect.LicenseDsc.Constraints
{
Expand All @@ -29,19 +21,19 @@ namespace CAS.Lib.CodeProtect.LicenseDsc.Constraints
/// <seealso cref="AbstractConstraint">AbstractConstraint</seealso>
/// <seealso cref="IConstraint">IConstraint</seealso>
/// <seealso cref="LicenseFile">LicenseFile</seealso>
public class FunctionConstraint: AbstractConstraint
public class FunctionConstraint : AbstractConstraint
{
#region private
private bool m_Allows = true;
private String updateUrl = String.Empty;
private string updateUrl = string.Empty;
#endregion

#region public constructors
/// <summary>
/// This is the constructor for the <see cref="FunctionConstraint"/>. The constructor
/// is used to create the object with a valid license to attach it to.
/// </summary>
public FunctionConstraint() : this( null ) { }
public FunctionConstraint() : this(null) { }
/// <summary>
/// This is the constructor for the <see cref="FunctionConstraint"/>. The constructor
/// is used to create the object and assign it to the proper license.
Expand All @@ -50,7 +42,7 @@ public FunctionConstraint() : this( null ) { }
/// The <see cref="LicenseFile">LicenseFile</see> this constraint
/// belongs to.
/// </param>
public FunctionConstraint( LicenseFile license )
public FunctionConstraint(LicenseFile license)
{
base.License = license;
base.Name = Resources.FunctionConstraintName;
Expand All @@ -64,15 +56,15 @@ public FunctionConstraint( LicenseFile license )
/// <param name="cStr">The stringBuilder class where information should be stored</param>
/// <param name="additionalInformation">The additional information.</param>
/// <param name="depth">The depth (Indentation level).</param>
protected internal override void PrepareTextInformationAboutConstraint( StringBuilder cStr, string additionalInformation, int depth )
protected internal override void PrepareTextInformationAboutConstraint(StringBuilder cStr, string additionalInformation, int depth)
{
StringBuilder sb_addtionalInfo = new StringBuilder();
DoIndent( sb_addtionalInfo, depth );
if ( Allow )
sb_addtionalInfo.AppendLine( Resources.FunctionConstraint_Allowed );
DoIndent(sb_addtionalInfo, depth);
if (Allow)
sb_addtionalInfo.AppendLine(Resources.FunctionConstraint_Allowed);
else
sb_addtionalInfo.AppendLine( Resources.FunctionConstraint_NOTAllowed );
base.PrepareTextInformationAboutConstraint( cStr, sb_addtionalInfo.ToString(), depth );
sb_addtionalInfo.AppendLine(Resources.FunctionConstraint_NOTAllowed);
base.PrepareTextInformationAboutConstraint(cStr, sb_addtionalInfo.ToString(), depth);
}
/// <summary>
/// <p>This verifies the license meets its desired validation criteria. This includes
Expand All @@ -94,16 +86,16 @@ protected internal override void PrepareTextInformationAboutConstraint( StringBu
/// \t{UpdateURL}
/// </code>
/// </remarks>
public override bool Validate( Type typeToValidate, ref int vc, ref int rtc )
public override bool Validate(Type typeToValidate, ref int vc, ref int rtc)
{
if ( !base.Validate( typeToValidate, ref vc, ref rtc ) )
if (!base.Validate(typeToValidate, ref vc, ref rtc))
return false;
if ( m_Allows )
if (m_Allows)
return true;
StringBuilder errStr = new StringBuilder();
errStr.Append( String.Format( Resources.LicMessageFunctionNotAllowed, this.Name, this.UpdateURL ) );
errStr.Append($"{Resources.LicMessageFunctionNotAllowed} {this.Name}; {Resources.GetUpgrade} {this.UpdateURL}");
errStr.AppendLine();
AddFailureReasonText( errStr.ToString() );
AddFailureReasonText(errStr.ToString());
return false;
}
/// <summary>
Expand All @@ -115,15 +107,15 @@ public override bool Validate( Type typeToValidate, ref int vc, ref int rtc )
/// <exception cref="ArgumentNullException">
/// Thrown if the <see cref="XmlNode">XmlNode</see> is null.
/// </exception>
public override void FromXml( XmlNode itemsNode )
public override void FromXml(XmlNode itemsNode)
{
base.FromXml( itemsNode );
XmlNode updateURLTextNode = itemsNode.SelectSingleNode( "UpdateUrl/text()" );
if ( updateURLTextNode != null )
base.FromXml(itemsNode);
XmlNode updateURLTextNode = itemsNode.SelectSingleNode("UpdateUrl/text()");
if (updateURLTextNode != null)
UpdateURL = updateURLTextNode.Value;
XmlNode allowed = itemsNode.SelectSingleNode( "Allow/text()" );
if ( allowed != null )
Allow = Convert.ToBoolean( allowed.Value );
XmlNode allowed = itemsNode.SelectSingleNode("Allow/text()");
if (allowed != null)
Allow = Convert.ToBoolean(allowed.Value);
}
#endregion AbstractConstraint implementation
#region AbstractLicenseData implementation
Expand All @@ -133,10 +125,10 @@ public override void FromXml( XmlNode itemsNode )
/// <returns>
/// A <c>String</c> representing the FunctionConstraint as Xml data.
/// </returns>
protected override void ToXmlString( XmlTextWriter xmlWriter )
protected override void ToXmlString(XmlTextWriter xmlWriter)
{
xmlWriter.WriteElementString( "UpdateUrl", this.UpdateURL );
xmlWriter.WriteElementString( "Allow", Convert.ToString( Allow ) );
xmlWriter.WriteElementString("UpdateUrl", this.UpdateURL);
xmlWriter.WriteElementString("Allow", Convert.ToString(Allow));
}
#endregion AbstractLicenseData implementation
#region Properties
Expand All @@ -150,22 +142,19 @@ protected override void ToXmlString( XmlTextWriter xmlWriter )
/// Gets the end date/time for this <see cref="FunctionConstraint">FunctionConstraint</see>.
/// </returns>
[
Bindable( false ),
Browsable( true ),
Category( "Constraints" ),
DefaultValue( null ),
Description( "Gets or sets the allow property. If the value is false the constrain is not valid" ),
DesignerSerializationVisibility( DesignerSerializationVisibility.Visible )
Bindable(false),
Browsable(true),
Category("Constraints"),
DefaultValue(null),
Description("Gets or sets the allow property. If the value is false the constrain is not valid"),
DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)
]
public bool Allow
{
get
{
return this.m_Allows;
}
get => this.m_Allows;
set
{
if ( !this.m_Allows.Equals( value ) )
if (!this.m_Allows.Equals(value))
{
this.m_Allows = value;
this.IsModified = true;
Expand All @@ -178,25 +167,22 @@ public bool Allow
/// </summary>
/// <value>The new URL.</value>
/// <returns>
/// Returns the URL, as a <see cref="String"/>, which points to where an update can be obtained.
/// Returns the URL, as a <see cref="string"/>, which points to where an update can be obtained.
/// </returns>
[
Bindable( false ),
Browsable( true ),
Category( "Data" ),
DefaultValue( "" ),
Description( "Gets or Sets the URL, as a String, which points to where an update can be obtained." ),
DesignerSerializationVisibility( DesignerSerializationVisibility.Visible )
Bindable(false),
Browsable(true),
Category("Data"),
DefaultValue(""),
Description("Gets or Sets the URL, as a String, which points to where an update can be obtained."),
DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)
]
public string UpdateURL
{
get
{
return this.updateUrl;
}
get => this.updateUrl;
set
{
if ( !this.UpdateURL.Equals( value ) )
if (!this.UpdateURL.Equals(value))
{
this.updateUrl = value;
this.IsModified = true;
Expand Down
Binary file added CAS.CodeProtect/Logo.ico
Binary file not shown.
Binary file added CAS.CodeProtect/Logo64.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit cd17bfe

Please sign in to comment.