public override string Serialize()
        {
            StringBuilder msg = new StringBuilder("$ID");

            msg.Append(From);
            msg.Append(DELIMITER);
            msg.Append(To);
            msg.Append(DELIMITER);
            msg.Append(ClientID.ToString("x4"));
            msg.Append(DELIMITER);
            msg.Append(ClientName);
            msg.Append(DELIMITER);
            msg.Append(MajorVersion.ToString());
            msg.Append(DELIMITER);
            msg.Append(MinorVersion.ToString());
            msg.Append(DELIMITER);
            msg.Append(CID);
            msg.Append(DELIMITER);
            msg.Append(SysUID);
            if (!string.IsNullOrEmpty(InitialChallenge))
            {
                msg.Append(DELIMITER);
                msg.Append(InitialChallenge);
            }
            return(msg.ToString());
        }
Example #2
0
 public override void DumpBody(XmlWriter writer)
 {
     writer.WriteElementString("url", Url);
     writer.WriteElementString("major-version", MajorVersion.ToString());
     writer.WriteElementString("minor-version", MinorVersion.ToString());
     Assets.DumpXml(writer);
 }
Example #3
0
 public override void DumpBody(XmlWriter writer)
 {
     writer.WriteElementString("product-id", ProductId.ToString());
     writer.WriteElementString("edition", Edition.ToString());
     writer.WriteElementString("major-version", MajorVersion.ToString());
     writer.WriteElementString("minor-version", MinorVersion.ToString());
     writer.WriteElementString("build-number", BuildNumber.ToString());
     writer.WriteElementString("build-date", BuildDate.ToString());
 }
Example #4
0
        public virtual void WriteXml(XmlDictionaryWriter writer,
                                     SamlSerializer samlSerializer,
                                     SecurityTokenSerializer keyInfoTokenSerializer)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }

            if (Issuer == null || Issuer.Length == 0)
            {
                throw new SecurityTokenException("Issuer must not be null or empty.");
            }
            if (Statements.Count == 0)
            {
                throw new SecurityTokenException("At least one assertion statement is required.");
            }

            if (samlSerializer == null)
            {
                throw new ArgumentNullException("samlSerializer");
            }
            CultureInfo invariant = CultureInfo.InvariantCulture;

            writer.WriteStartElement("saml", "Assertion", SamlConstants.Namespace);
            writer.WriteAttributeString("MajorVersion", MajorVersion.ToString(invariant));
            writer.WriteAttributeString("MinorVersion", MinorVersion.ToString(invariant));
            writer.WriteAttributeString("AssertionID", AssertionId);
            writer.WriteAttributeString("Issuer", Issuer);
            writer.WriteAttributeString("IssueInstant", IssueInstant.ToString(SamlConstants.DateFormat, invariant));

            try
            {
                if (Conditions != null)
                {
                    Conditions.WriteXml(writer, samlSerializer, keyInfoTokenSerializer);
                }
                if (Advice != null)
                {
                    Advice.WriteXml(writer, samlSerializer, keyInfoTokenSerializer);
                }
                foreach (SamlStatement statement in Statements)
                {
                    statement.WriteXml(writer, samlSerializer, keyInfoTokenSerializer);
                }
            }
            catch (NotImplementedException)
            {
                throw;
            }
            catch (Exception ex) // bad catch, eh?
            {
                throw new InvalidOperationException("There is an error on writing assertion statements.", ex);
            }
            writer.WriteEndElement();
        }
Example #5
0
 public override void WriteMetadata(StringBuilder builder)
 {
     builder.Append(Encoding.ASCII.GetString(HttpMethodBytes.GetBytes(Method)));
     builder.Append(" ");
     builder.Append(Path);
     builder.Append(" HTTP/");
     builder.Append(MajorVersion.ToString(CultureInfo.InvariantCulture));
     builder.Append(".");
     builder.Append(MinorVersion.ToString(CultureInfo.InvariantCulture));
     builder.Append("\r\n");
     Headers.Write(builder, null, Encoding.ASCII);
 }
Example #6
0
        /// <summary>
        /// Provide an XML version of the extension
        /// </summary>
        /// <returns>XML encoding of the extension</returns>
        /// <remarks>Sample OSCA XML description of the CertTemplateInfo extension:
        /// <code>
        ///  &lt;Extension&gt;
        ///    &lt;name description="Certificate Template Information"&gt;CertTemplateInfo&lt;/name&gt;
        ///    &lt;critical&gt;false&lt;/critical&gt;
        ///    &lt;value&gt;
        ///        &lt;template&gt;1.2.3.4.5.6&lt;/template&gt;
        ///        &lt;majorVersion&gt;1&lt;/majorVersion&gt;
        ///        &lt;minorVersion&gt;4&lt;/minorVersion&gt;
        ///    &lt;/value&gt;
        ///  &lt;/Extension&gt;
        /// </code>
        /// </remarks>
        public override XNode ToXml()
        {
            // Build generic
            XElement extension = (XElement)base.ToXml();

            // Create the parameter list
            XElement entry = extension.Element("value");

            entry.Add(new XElement("template", Template));
            entry.Add(new XElement("majorVersion", MajorVersion.ToString()));
            entry.Add(new XElement("minorVersion", MinorVersion.ToString()));
            return(extension);
        }
Example #7
0
            /// <summary>
            /// Returns negative integer if <see cref="MajorVersion"/> is behind to <see cref="secondMajorVerion"/>
            /// otherwise returns 0 if both are equal or positive integer if <see cref="MajorVersion"/> is ahead of <see cref="secondMajorVerion"/>
            /// </summary>
            /// <param name="secondMajorVerion">secondMajorVerion</param>
            /// <returns>substraction of <see cref="MajorVersion"/> and <see cref="secondMajorVerion"/></returns>
            public int CompareMajorVersion(float secondMajorVerion)
            {
                float  x;
                double xTruncate;

                if (BitConverter.GetBytes(decimal.GetBits((decimal)MajorVersion)[3])[2] == 1)
                {
                    var temp   = MajorVersion.ToString(System.Globalization.CultureInfo.InvariantCulture).Split('.');
                    var joined = $"{temp[0]}.0{temp[1]}";
                    x = Convert.ToSingle(joined);

                    xTruncate = Math.Truncate(x);
                }
                else
                {
                    x         = MajorVersion;
                    xTruncate = Math.Truncate(MajorVersion);
                }

                float  y;
                double yTruncate;

                if (BitConverter.GetBytes(decimal.GetBits((decimal)secondMajorVerion)[3])[2] == 1)
                {
                    var temp   = secondMajorVerion.ToString(System.Globalization.CultureInfo.InvariantCulture).Split('.');
                    var joined = $"{temp[0]}.0{temp[1]}";
                    y = Convert.ToSingle(joined);

                    yTruncate = Math.Truncate(y);
                }
                else
                {
                    y         = secondMajorVerion;
                    yTruncate = Math.Truncate(secondMajorVerion);
                }

                var xDecimalPart = x - xTruncate;
                var yDecimalPart = y - yTruncate;

                var result = Math.Round(xDecimalPart - yDecimalPart, 2) * 100 + (xTruncate - yTruncate);

                return((int)result);
            }
Example #8
0
            internal void RestoreLayout(Dock dock, DockableContextContentCreator contentCreator)
            {
                Dictionary <int, DockableCollection> dockableCollections = new Dictionary <int, DockableCollection>();

                if (MajorVersion != MetadataMajorVersion || MinorVersion > MetadataMinorVersion)
                {
                    throw new InvalidDataException("Saved layout version (" + MajorVersion.ToString() + "." + MinorVersion.ToString() +
                                                   " is not compatible with the expected version " + MetadataMajorVersion.ToString() + "." + MetadataMinorVersion.ToString());
                }

                //  First, create the collections and associate them with the dock

                foreach (DockableCollectionDescriptor desc in DockedCollections)
                {
                    DockableCollection newCollection = desc.Create(dock, contentCreator);
                    dockableCollections.Add(desc.InternalId, newCollection);
                }


                //  Next, resolve their peer associations

                foreach (DockableCollectionDescriptor desc in DockedCollections)
                {
                    DockableCollection dockableCollection = dockableCollections[desc.InternalId];
                    desc.ResolvePeerRelationships(dockableCollections, dockableCollection);
                }

                dock.InvalidatePhysical();

                if (dock.ActualWidth != DockSize.Width || dock.ActualHeight != DockSize.Height)
                {
                    dock.InvalidatePositioning(LayoutContext.PositionClasses.EveryCollection | LayoutContext.PositionClasses.All | LayoutContext.PositionClasses.Resize);
                }

                foreach (DockDescriptor desc in FloatingDocks)
                {
                    dock.CreateFloatingDock(desc.Position, desc.DockSize, (DockWindow dockWindow) =>
                    {
                        desc.RestoreLayout(dockWindow.Dock, contentCreator);
                    });
                }
            }
Example #9
0
        public override string ToString()
        {
            // Start with the unix epoch of Jan, 1, 1970.
            var compTime = new DateTime(1970, 1, 1, 0, 0, 0, 0);

            // Add the total seconds to the epoch.
            compTime = compTime.AddSeconds(Convert.ToDouble(CompilationTime));

            var sb = new StringBuilder();

            sb.Append($"Magic: {Magic.ToString("X8")} ");
            sb.Append($"Major: {MajorVersion.ToString("X2")} ");
            sb.Append($"Minor: {MinorVersion.ToString("X2")} ");
            sb.Append($"Game ID: {GameID.ToString("X4")} ");
            sb.Append($"Compile: {compTime}{Environment.NewLine}");
            sb.Append($"Script Name: {SourceFileName}{Environment.NewLine}");
            sb.Append($"User Name: {UserName}{Environment.NewLine}");
            sb.Append($"Computer Name: {ComputerName}");
            return(sb.ToString());
        }
Example #10
0
        public StudioVersion(string versionName, string publicVersion, string edition = "")
        {
            VersionName    = $"{versionName}{edition}";
            PublicVersion  = publicVersion;
            Edition        = edition;
            SdlRegistryKey = $"{SdlBaseRegistryKey}{AppDataStudioFolder}";

            var pluginPath = Path.Combine(SdlFolder, $"{MajorVersion}{edition}");
            var programDataStudioFolderPath = Path.Combine(SdlFolder, ProgramDataStudioFolder);

            ProgramDataStudioPath = Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData),
                programDataStudioFolderPath);

            ProgramDataPluginsPath = Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData),
                pluginPath);

            var appDataStudioFolderPath = Path.Combine(SdlFolder, AppDataStudioFolder);

            AppDataLocalStudioPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
                                                  appDataStudioFolderPath);

            AppDataLocalPluginsPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
                                                   pluginPath);

            AppDataRoamingStudioPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                                                    appDataStudioFolderPath);

            AppDataRoamingPluginsPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                                                     pluginPath);

            ShortVersion = publicVersion.Substring(11);

            DocumentsPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), ShortVersion);

            ProjectsXmlPath = Path.Combine(DocumentsPath, "Projects", "projects.xml");

            ProgramDataStudioDataSubfolderPath = $@"{ProgramDataStudioPath}\Updates";

            ProjectTemplatesPath = $@"{DocumentsPath}\Project Templates";

            ProjectApiPath = Directory.GetDirectories(Path.Combine(
                                                          Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                                                          "SDL", "ProjectApi")).FirstOrDefault(d => d.Contains(MajorVersion.ToString()));
        }
        internal override string GetRtfFormattedRule()
        {
            RichTextBox rTxtBx = new RichTextBox();

            if (UseMajorVersion || UseProductType)
            {
                if (ReverseRule)
                {
                    print(rTxtBx, GroupDisplayer.normalFont, GroupDisplayer.green, "<lar:");
                    print(rTxtBx, GroupDisplayer.boldFont, GroupDisplayer.black, "Not");
                    print(rTxtBx, GroupDisplayer.normalFont, GroupDisplayer.green, ">\r\n");
                }

                print(rTxtBx, GroupDisplayer.normalFont, GroupDisplayer.black, "<bar:");
                print(rTxtBx, GroupDisplayer.elementAndAttributeFont, GroupDisplayer.red, "WindowsVersion");

                if (UseComparison)
                {
                    print(rTxtBx, GroupDisplayer.elementAndAttributeFont, GroupDisplayer.blue, " Comparison");
                    print(rTxtBx, GroupDisplayer.normalFont, GroupDisplayer.black, "=\"");
                    print(rTxtBx, GroupDisplayer.boldFont, GroupDisplayer.black, Comparison);
                    print(rTxtBx, GroupDisplayer.normalFont, GroupDisplayer.black, "\"");
                }

                if (UseMajorVersion)
                {
                    print(rTxtBx, GroupDisplayer.elementAndAttributeFont, GroupDisplayer.blue, " MajorVersion");
                    print(rTxtBx, GroupDisplayer.normalFont, GroupDisplayer.black, "=\"");
                    print(rTxtBx, GroupDisplayer.boldFont, GroupDisplayer.black, MajorVersion.ToString());
                    print(rTxtBx, GroupDisplayer.normalFont, GroupDisplayer.black, "\"");
                }

                if (UseMinorVersion)
                {
                    print(rTxtBx, GroupDisplayer.elementAndAttributeFont, GroupDisplayer.blue, " MinorVersion");
                    print(rTxtBx, GroupDisplayer.normalFont, GroupDisplayer.black, "=\"");
                    print(rTxtBx, GroupDisplayer.boldFont, GroupDisplayer.black, MinorVersion.ToString());
                    print(rTxtBx, GroupDisplayer.normalFont, GroupDisplayer.black, "\"");
                }

                if (UseBuildNumber)
                {
                    print(rTxtBx, GroupDisplayer.elementAndAttributeFont, GroupDisplayer.blue, " BuildNumber");
                    print(rTxtBx, GroupDisplayer.normalFont, GroupDisplayer.black, "=\"");
                    print(rTxtBx, GroupDisplayer.boldFont, GroupDisplayer.black, BuildNumber.ToString());
                    print(rTxtBx, GroupDisplayer.normalFont, GroupDisplayer.black, "\"");
                }

                if (UseServicePackMajor)
                {
                    print(rTxtBx, GroupDisplayer.elementAndAttributeFont, GroupDisplayer.blue, " ServicePackMajor");
                    print(rTxtBx, GroupDisplayer.normalFont, GroupDisplayer.black, "=\"");
                    print(rTxtBx, GroupDisplayer.boldFont, GroupDisplayer.black, ServicePackMajor.ToString());
                    print(rTxtBx, GroupDisplayer.normalFont, GroupDisplayer.black, "\"");
                }

                if (UseServicePackMinor)
                {
                    print(rTxtBx, GroupDisplayer.elementAndAttributeFont, GroupDisplayer.blue, " ServicePackMinor");
                    print(rTxtBx, GroupDisplayer.normalFont, GroupDisplayer.black, "=\"");
                    print(rTxtBx, GroupDisplayer.boldFont, GroupDisplayer.black, ServicePackMinor.ToString());
                    print(rTxtBx, GroupDisplayer.normalFont, GroupDisplayer.black, "\"");
                }

                if (UseProductType)
                {
                    print(rTxtBx, GroupDisplayer.elementAndAttributeFont, GroupDisplayer.blue, " ProductType");
                    print(rTxtBx, GroupDisplayer.normalFont, GroupDisplayer.black, "=\"");
                    print(rTxtBx, GroupDisplayer.boldFont, GroupDisplayer.black, ProductType.ToString());
                    print(rTxtBx, GroupDisplayer.normalFont, GroupDisplayer.black, "\"");
                }

                print(rTxtBx, GroupDisplayer.normalFont, GroupDisplayer.black, "/>");

                if (ReverseRule)
                {
                    print(rTxtBx, GroupDisplayer.normalFont, GroupDisplayer.black, "\r\n");
                    print(rTxtBx, GroupDisplayer.normalFont, GroupDisplayer.green, "</lar:");
                    print(rTxtBx, GroupDisplayer.boldFont, GroupDisplayer.black, "Not");
                    print(rTxtBx, GroupDisplayer.normalFont, GroupDisplayer.green, ">");
                }
            }
            return(rTxtBx.Rtf);
        }
Example #12
0
 public override string ToString()
 {
     return(string.Format("sc{0}{1}{2}", MajorVersion.ToString("00"), MinorVersion.ToString("00"), ScriptVersion.ToString("00")));
 }
Example #13
0
 public override string ToString()
 {
     return($"{MajorVersion.ToString("F")}.{MinorVersion}.{PatchVersion}");
 }