/// <summary> /// 通过密钥,对字符串形式的加密数据进行解密 /// </summary> /// <param name="bytes"></param> /// <param name="SecretKey">密钥</param> /// <param name="SingleLine">True:解析单行;False:解析所有</param> /// <param name="Standard">是否使用标准方式</param> /// <returns></returns> public static string Decrypt(this byte[] bytes, string SecretKey, bool SingleLine = true, bool Standard = false) { DESCryptoServiceProvider des = new DESCryptoServiceProvider(); if (Standard) { des.Mode = CipherMode.ECB; des.Padding = PaddingMode.Zeros; } des.Key = SecretKey.ToMD5().Substring(0, 0x08).ToBytes(); des.IV = SecretKey.ToMD5().Substring(0, 0x08).ToBytes(); global::System.IO.MemoryStream ms = new global::System.IO.MemoryStream(bytes); string val = string.Empty; try { CryptoStream encStream = new CryptoStream(ms, des.CreateDecryptor(), CryptoStreamMode.Read); global::System.IO.StreamReader sr = new global::System.IO.StreamReader(encStream); val = SingleLine ? sr.ReadLine() : sr.ReadToEnd(); sr.Close(); encStream.Close(); } catch { val = "密钥错误,解密失败。"; } finally { ms.Close(); } return val; }
/// <summary> /// 通过密钥对文本进行加密 /// </summary> /// <param name="str"></param> /// <param name="SecretKey">密钥</param> /// <param name="SingleLine">True:单行;False:所有</param> /// <param name="Standard">是否使用标准方式</param> /// <returns>加密后的文本</returns> public static string Encrypt(this string str, string SecretKey, bool SingleLine = true, bool Standard = false) { DESCryptoServiceProvider des = new DESCryptoServiceProvider(); if (Standard) { des.Mode = CipherMode.ECB; des.Padding = PaddingMode.Zeros; } des.Key = SecretKey.ToMD5().Substring(0, 0x08).ToBytes(); des.IV = SecretKey.ToMD5().Substring(0, 0x08).ToBytes(); global::System.IO.MemoryStream ms = new global::System.IO.MemoryStream(); CryptoStream encStream = new CryptoStream(ms, des.CreateEncryptor(), CryptoStreamMode.Write); global::System.IO.StreamWriter sw = new global::System.IO.StreamWriter(encStream); if (SingleLine) sw.WriteLine(str); else sw.Write(str); sw.Close(); encStream.Close(); byte[] buffer = ms.ToArray(); ms.Close(); StringBuilder hash = new StringBuilder(); foreach (byte b in buffer.ToArray()) { hash.AppendFormat("{0:X2}", b); } return hash.ToString(); }
private global::System.IO.MemoryStream InternalSaveDiagram2(DslModeling::SerializationResult serializationResult, PatternModelSchemaDiagram diagram, string diagramFileName, global::System.Text.Encoding encoding, bool writeOptionalPropertiesWithDefaultValue) { #region Check Parameters global::System.Diagnostics.Debug.Assert(serializationResult != null); global::System.Diagnostics.Debug.Assert(diagram != null); global::System.Diagnostics.Debug.Assert(!serializationResult.Failed); #endregion DslModeling::DomainXmlSerializerDirectory directory = this.GetDirectory(diagram.Store); global::System.IO.MemoryStream newFileContent = new global::System.IO.MemoryStream(); DslModeling::SerializationContext serializationContext = new DslModeling::SerializationContext(directory, diagramFileName, serializationResult); this.InitializeSerializationContext(diagram.Partition, serializationContext, false); // MonikerResolver shouldn't be required in Save operation, so not calling SetupMonikerResolver() here. serializationContext.WriteOptionalPropertiesWithDefaultValue = writeOptionalPropertiesWithDefaultValue; global::System.Xml.XmlWriterSettings settings = PatternModelSerializationHelper.Instance.CreateXmlWriterSettings(serializationContext, true, encoding); using (global::System.Xml.XmlWriter writer = global::System.Xml.XmlWriter.Create(newFileContent, settings)) { this.WriteRootElement(serializationContext, diagram, writer); } return newFileContent; }
public virtual global::haxe.io.Bytes getBytes() { unchecked { byte[] buf = this.b.GetBuffer(); global::haxe.io.Bytes bytes = new global::haxe.io.Bytes(((int) (( this.b as global::System.IO.Stream ).Length) ), ((byte[]) (buf) )); this.b = default(global::System.IO.MemoryStream); return bytes; } }
public string ConvertLayoutInfoToString(LayoutInfo info) { string result = String.Empty; Microsoft.VisualStudio.Modeling.SerializationResult serializationResult = new Microsoft.VisualStudio.Modeling.SerializationResult(); DomainXmlSerializerDirectory directory = this.GetDirectory(info.Store); System.Text.Encoding encoding = System.Text.Encoding.GetEncoding("ISO-8859-1"); Microsoft.VisualStudio.Modeling.SerializationContext serializationContext = new SerializationContext(directory, "", serializationResult); this.InitializeSerializationContext(info.Partition, serializationContext, false); global::System.IO.MemoryStream newFileContent = new global::System.IO.MemoryStream(); global::System.Xml.XmlWriterSettings settings = DiagramsDSLSerializationHelper.Instance.CreateXmlWriterSettings(serializationContext, false, encoding); using (global::System.Xml.XmlWriter writer = global::System.Xml.XmlWriter.Create(newFileContent, settings)) { DomainClassXmlSerializer rootSerializer = directory.GetSerializer(LayoutInfo.DomainClassId); RootElementSettings rootElementSettings = new RootElementSettings(); rootElementSettings.SchemaTargetNamespace = "http://schemas.microsoft.com/dsltools/DiagramsDSL"; rootElementSettings.Version = new global::System.Version("1.0.0.0"); // Carry out the normal serialization. rootSerializer.Write(serializationContext, info, writer, rootElementSettings); } char[] chars = encoding.GetChars(newFileContent.GetBuffer()); // search the open angle bracket and trim off the Byte Of Mark. result = new string(chars); int indexPos = result.IndexOf('<'); if (indexPos > 0) { // strip off the leading Byte Of Mark. result = result.Substring(indexPos); } // trim off trailing 0s. result = result.TrimEnd('\0'); return result; }
public override object __hx_setField(string field, int hash, object @value, bool handleProperties) { unchecked { switch (hash) { case 98: { this.b = ((global::System.IO.MemoryStream) (@value) ); return @value; } default: { return base.__hx_setField(field, hash, @value, handleProperties); } } } }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]protected override global::System.Xml.Schema.XmlSchema GetSchemaSerializable() { global::System.IO.MemoryStream stream = new global::System.IO.MemoryStream(); this.WriteXmlSchema(new global::System.Xml.XmlTextWriter(stream, null)); stream.Position = 0; return global::System.Xml.Schema.XmlSchema.Read(new global::System.Xml.XmlTextReader(stream), null); }
global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")]protected override global::System.Xml.Schema.XmlSchema GetSchemaSerializable() { global::System.IO.MemoryStream stream = new global::System.IO.MemoryStream(); this.WriteXmlSchema(new global::System.Xml.XmlTextWriter(stream, null)); stream.Position = 0; return global::System.Xml.Schema.XmlSchema.Read(new global::System.Xml.XmlTextReader(stream), null); }
global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")]public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) { DS_LICENSESOFTWARE ds = new DS_LICENSESOFTWARE(); global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); while (schemas.MoveNext()) { schema = (global::System.Xml.Schema.XmlSchema) schemas.Current; s2.SetLength(0); schema.Write(s2); if (s1.Length == s2.Length) { s1.Position = 0; s2.Position = 0; while ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte())) { } if (s1.Position == s1.Length) { return type; } } } } finally { if (!((s1) == null)) { s1.Close(); } if (!((s2) == null)) { s2.Close(); } } } xs.Add(dsSchema); return type; }
internal virtual void SaveModel(DslModeling::SerializationResult serializationResult, ProductState modelRoot, string fileName, global::System.Text.Encoding encoding, bool writeOptionalPropertiesWithDefaultValue) { #region Check Parameters if (serializationResult == null) throw new global::System.ArgumentNullException("serializationResult"); if (modelRoot == null) throw new global::System.ArgumentNullException("modelRoot"); if (string.IsNullOrEmpty(fileName)) throw new global::System.ArgumentNullException("fileName"); #endregion if (serializationResult.Failed) return; using (global::System.IO.MemoryStream newFileContent = new global::System.IO.MemoryStream()) { DslModeling::DomainXmlSerializerDirectory directory = this.GetDirectory(modelRoot.Store); DslModeling::SerializationContext serializationContext = new DslModeling::SerializationContext(directory, fileName, serializationResult); this.InitializeSerializationContext(modelRoot.Partition, serializationContext, false); // MonikerResolver shouldn't be required in Save operation, so not calling SetupMonikerResolver() here. serializationContext.WriteOptionalPropertiesWithDefaultValue = writeOptionalPropertiesWithDefaultValue; global::System.Xml.XmlWriterSettings settings = ProductStateStoreSerializationHelper.Instance.CreateXmlWriterSettings(serializationContext, false, encoding); using (global::System.Xml.XmlWriter writer = global::System.Xml.XmlWriter.Create(newFileContent, settings)) { this.WriteRootElement(serializationContext, modelRoot, writer); } if (!serializationResult.Failed && newFileContent != null) { // Only write the content if there's no error encountered during serialization. using (global::System.IO.FileStream fileStream = new global::System.IO.FileStream(fileName, global::System.IO.FileMode.Create, global::System.IO.FileAccess.Write, global::System.IO.FileShare.None)) { using (global::System.IO.BinaryWriter writer = new global::System.IO.BinaryWriter(fileStream, encoding)) { writer.Write(newFileContent.ToArray()); } } } } }
private global::System.IO.MemoryStream InternalSaveDiagram(DslModeling::SerializationResult serializationResult, AsyncDslDiagram diagram, string diagramFileName, global::System.Text.Encoding encoding, bool writeOptionalPropertiesWithDefaultValue) { #region Check Parameters global::System.Diagnostics.Debug.Assert(serializationResult != null); global::System.Diagnostics.Debug.Assert(diagram != null); global::System.Diagnostics.Debug.Assert(!serializationResult.Failed); #endregion global::System.IO.MemoryStream newFileContent = new global::System.IO.MemoryStream(); DslModeling::DomainClassXmlSerializer diagramSerializer = this.Directory.GetSerializer(diagram.GetDomainClass().Id); global::System.Diagnostics.Debug.Assert(diagramSerializer != null, "Cannot find serializer for " + diagram.GetDomainClass().Name + "!"); if (diagramSerializer != null) { DslModeling::SerializationContext serializationContext = new DslModeling::SerializationContext(this.Directory, diagramFileName, serializationResult); // MonikerResolver shouldn't be required in Save operation, so not calling SetupMonikerResolver() here. serializationContext.WriteOptionalPropertiesWithDefaultValue = writeOptionalPropertiesWithDefaultValue; global::System.Xml.XmlWriterSettings settings = new global::System.Xml.XmlWriterSettings(); settings.Indent = true; settings.Encoding = encoding; using (global::System.IO.StreamWriter streamWriter = new global::System.IO.StreamWriter(newFileContent, encoding)) { using (global::System.Xml.XmlWriter writer = global::System.Xml.XmlWriter.Create(streamWriter, settings)) { diagramSerializer.WriteRootElement(serializationContext, diagram, writer); } } } return newFileContent; }
protected override global::System.Xml.Schema.XmlSchema GetSchemaSerializable() { global::System.IO.MemoryStream stream = new global::System.IO.MemoryStream(); this.WriteXmlSchema(new global::System.Xml.XmlTextWriter(stream, null)); stream.Position = 0; return global::System.Xml.Schema.XmlSchema.Read(new global::System.Xml.XmlTextReader(stream), null); }
public virtual void SaveModelAndDiagram(DslModeling::SerializationResult serializationResult, Model modelRoot, string modelFileName, ActiveRecordMapping diagram, string diagramFileName, global::System.Text.Encoding encoding, bool writeOptionalPropertiesWithDefaultValue) { #region Check Parameters if (serializationResult == null) throw new global::System.ArgumentNullException("serializationResult"); if (string.IsNullOrEmpty(modelFileName)) throw new global::System.ArgumentNullException("modelFileName"); if (diagram == null) throw new global::System.ArgumentNullException("diagram"); if (string.IsNullOrEmpty(diagramFileName)) throw new global::System.ArgumentNullException("diagramFileName"); #endregion if (serializationResult.Failed) return; // Save the model file first using (global::System.IO.MemoryStream modelFileContent = this.InternalSaveModel(serializationResult, modelRoot, modelFileName, encoding, writeOptionalPropertiesWithDefaultValue)) { if (serializationResult.Failed) return; using (global::System.IO.MemoryStream diagramFileContent = new global::System.IO.MemoryStream()) { DslModeling::DomainClassXmlSerializer diagramSerializer = this.Directory.GetSerializer(diagram.GetDomainClass().Id); global::System.Diagnostics.Debug.Assert(diagramSerializer != null, "Cannot find serializer for " + diagram.GetDomainClass().Name + "!"); if (diagramSerializer != null) { DslModeling::SerializationContext serializationContext = new DslModeling::SerializationContext(this.Directory, diagramFileName, serializationResult); // MonikerResolver shouldn't be required in Save operation, so not calling SetupMonikerResolver() here. serializationContext.WriteOptionalPropertiesWithDefaultValue = writeOptionalPropertiesWithDefaultValue; global::System.Xml.XmlWriterSettings settings = new global::System.Xml.XmlWriterSettings(); settings.Indent = true; settings.Encoding = encoding; using (global::System.IO.StreamWriter streamWriter = new global::System.IO.StreamWriter(diagramFileContent, encoding)) { using (global::System.Xml.XmlWriter writer = global::System.Xml.XmlWriter.Create(streamWriter, settings)) { diagramSerializer.WriteRootElement(serializationContext, diagram, writer); } } } if (!serializationResult.Failed) { // Only write the contents if there's no error encountered during serialization. if (modelFileContent != null) { using (global::System.IO.FileStream fileStream = new global::System.IO.FileStream(modelFileName, global::System.IO.FileMode.Create, global::System.IO.FileAccess.Write, global::System.IO.FileShare.None)) { using (global::System.IO.BinaryWriter writer = new global::System.IO.BinaryWriter(fileStream, encoding)) { writer.Write(modelFileContent.ToArray()); } } } if (diagramFileContent != null) { using (global::System.IO.FileStream fileStream = new global::System.IO.FileStream(diagramFileName, global::System.IO.FileMode.Create, global::System.IO.FileAccess.Write, global::System.IO.FileShare.None)) { using (global::System.IO.BinaryWriter writer = new global::System.IO.BinaryWriter(fileStream, encoding)) { writer.Write(diagramFileContent.ToArray()); } } } } } } }
public void Deserialization() { global::System.Runtime.Serialization.IFormatter fmtr = new global::System.Runtime.Serialization.Formatters.Binary.BinaryFormatter (); global::System.IO.MemoryStream src; for (int i = 0; i < SerializationCases.Length; ++i) { src = new global::System.IO.MemoryStream ( BitConverter_ByteArray_FromString (SerializationCases[i].ResultBinaryString)); DateTimeOffset result = (DateTimeOffset)fmtr.Deserialize (src); #if false // DUMP_TO_CONSOLE Console.WriteLine ("#{0} input.o/s : {1}", i, SerializationCases[i].Input.Offset); Console.WriteLine ("#{0} result.o/s: {1}", i, result.Offset); Console.WriteLine ("#{0} input.dt : {1}={1:R}={1:u}", i, SerializationCases[i].Input.DateTime); Console.WriteLine ("#{0} result.dt: {1}={1:R}={1:u}", i, result.DateTime); Console.WriteLine ("#{0} input.dtK: {1}", i, SerializationCases[i].Input.DateTime.Kind); Console.WriteLine ("#{0} input : {1}={1:R}={1:u}", i, SerializationCases[i].Input); Console.WriteLine ("#{0} result: {1}={1:R}={1:u}", i, result); #endif Assert.AreEqual (SerializationCases[i].Input.Offset, result.Offset, ".Offset #" + i); Assert.AreEqual (SerializationCases[i].Input.DateTime, result.DateTime, ".DateTime #" + i); Assert.AreEqual (SerializationCases[i].Input, result, "equals #" + i); // DateTimeOffset always stores as Kind==Unspecified Assert.AreEqual (DateTimeKind.Unspecified, SerializationCases[i].Input.DateTime.Kind, ".DateTime.Kind==unspec #" + i); Assert.AreEqual (SerializationCases[i].Input.DateTime.Kind, result.DateTime.Kind, ".DateTime.Kind #" + i); }//for }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) { global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); EMDataSet ds = new EMDataSet(); global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny(); any1.Namespace = "http://www.w3.org/2001/XMLSchema"; any1.MinOccurs = new decimal(0); any1.MaxOccurs = decimal.MaxValue; any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any1); global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny(); any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; any2.MinOccurs = new decimal(1); any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any2); global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute1.Name = "namespace"; attribute1.FixedValue = ds.Namespace; type.Attributes.Add(attribute1); global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute2.Name = "tableTypeName"; attribute2.FixedValue = "CompanyTblDataTable"; type.Attributes.Add(attribute2); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte())); ) { ; } if ((s1.Position == s1.Length)) { return type; } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return type; }
public static global::Windows.Storage.Streams.IBuffer GetWindowsRuntimeBuffer(this global::System.IO.MemoryStream underlyingStream, int positionInStream, int length) { throw null; }
/// <summary> /// Constructs a new AggregateStateRelationshipConnectAction for the given Diagram. /// </summary> public AggregateStateRelationshipConnectAction(DslDiagrams::Diagram diagram): base(diagram, true) { global::System.Resources.ResourceManager resourceManager = global::FourDeep.Dizzle.DizzleDomainModel.SingletonResourceManager; global::System.Globalization.CultureInfo resourceCulture = global::System.Globalization.CultureInfo.CurrentUICulture; byte[] sourceCursorBytes = (byte[])resourceManager.GetObject("AggregateStateRelationshipSourceCursor", resourceCulture); using(global::System.IO.MemoryStream sourceCursorStream = new global::System.IO.MemoryStream(sourceCursorBytes)) { this.sourceCursor = new global::System.Windows.Forms.Cursor(sourceCursorStream); } byte[] targetCursorBytes = (byte[])resourceManager.GetObject("AggregateStateRelationshipTargetCursor", resourceCulture); using(global::System.IO.MemoryStream targetCursorStream = new global::System.IO.MemoryStream(targetCursorBytes)) { this.targetCursor = new global::System.Windows.Forms.Cursor(targetCursorStream); } }
/// <summary> /// Constructs a new InheritanceToolConnectAction for the given Diagram. /// </summary> public InheritanceToolConnectAction(DslDiagrams::Diagram diagram): base(diagram, true) { global::System.Resources.ResourceManager resourceManager = global::Microsoft.Data.Entity.Design.EntityDesigner.MicrosoftDataEntityDesignDomainModel.SingletonResourceManager; global::System.Globalization.CultureInfo resourceCulture = global::System.Globalization.CultureInfo.CurrentUICulture; byte[] sourceCursorBytes = (byte[])resourceManager.GetObject("InheritanceToolSourceCursor", resourceCulture); using(global::System.IO.MemoryStream sourceCursorStream = new global::System.IO.MemoryStream(sourceCursorBytes)) { this.sourceCursor = new global::System.Windows.Forms.Cursor(sourceCursorStream); } byte[] targetCursorBytes = (byte[])resourceManager.GetObject("InheritanceToolTargetCursor", resourceCulture); using(global::System.IO.MemoryStream targetCursorStream = new global::System.IO.MemoryStream(targetCursorBytes)) { this.targetCursor = new global::System.Windows.Forms.Cursor(targetCursorStream); } }
public override void SaveModel(DslModeling::SerializationResult serializationResult, MetaModel modelRoot, string fileName, global::System.Text.Encoding encoding, bool writeOptionalPropertiesWithDefaultValue) { base.SaveModel(serializationResult, modelRoot, fileName, encoding, writeOptionalPropertiesWithDefaultValue); System.IO.FileInfo info = new System.IO.FileInfo(fileName); string fileNameDiagram = info.DirectoryName + "\\" + info.Name.Remove(info.Name.Length - info.Extension.Length, info.Extension.Length) + DiagramExtension; // save view information using (global::System.IO.MemoryStream newFileContent = new global::System.IO.MemoryStream()) { DslModeling::DomainXmlSerializerDirectory directory = this.GetDirectory(modelRoot.Store); DslModeling::SerializationContext serializationContext = new DslModeling::SerializationContext(directory, fileName, serializationResult); this.InitializeSerializationContext(modelRoot.Partition, serializationContext, false); // MonikerResolver shouldn't be required in Save operation, so not calling SetupMonikerResolver() here. serializationContext.WriteOptionalPropertiesWithDefaultValue = writeOptionalPropertiesWithDefaultValue; global::System.Xml.XmlWriterSettings settings = LanguageDSLSerializationHelper.Instance.CreateXmlWriterSettings(serializationContext, false, encoding); using (global::System.Xml.XmlWriter writer = global::System.Xml.XmlWriter.Create(newFileContent, settings)) { ViewSerializer serializer = directory.GetSerializer(View.DomainClassId) as ViewSerializer; serializer.Write(serializationContext, modelRoot.View, writer); } if (!serializationResult.Failed && newFileContent != null) { // Only write the content if there's no error encountered during serialization. using (global::System.IO.FileStream fileStream = new global::System.IO.FileStream(fileNameDiagram, global::System.IO.FileMode.Create, global::System.IO.FileAccess.Write, global::System.IO.FileShare.None)) { using (global::System.IO.BinaryWriter writer = new global::System.IO.BinaryWriter(fileStream, encoding)) { writer.Write(newFileContent.ToArray()); } } } } }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) { global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); ContraVoucher ds = new ContraVoucher(); global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny(); any1.Namespace = "http://www.w3.org/2001/XMLSchema"; any1.MinOccurs = new decimal(0); any1.MaxOccurs = decimal.MaxValue; any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any1); global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny(); any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; any2.MinOccurs = new decimal(1); any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any2); global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute1.Name = "namespace"; attribute1.FixedValue = ds.Namespace; type.Attributes.Add(attribute1); global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute2.Name = "tableTypeName"; attribute2.FixedValue = "ContraVoucherDataTable"; type.Attributes.Add(attribute2); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }
private global::System.IO.MemoryStream InternalSaveModelVModell(DslModeling::SerializationResult serializationResult, global::Tum.VModellXT.VModell modelRoot, string fileName, global::System.Text.Encoding encoding, bool writeOptionalPropertiesWithDefaultValue, DslEditorModeling.SerializationMode serializationMode) { #region Check Parameters global::System.Diagnostics.Debug.Assert(serializationResult != null); global::System.Diagnostics.Debug.Assert(modelRoot != null); global::System.Diagnostics.Debug.Assert(!serializationResult.Failed); #endregion //DslEditorModeling::DomainModelStore dStore = (DslEditorModeling::DomainModelStore)modelRoot.Store; //if( dStore == null) // throw new global::System.ArgumentNullException("dStore"); //dStore.WaitForWritingLockRelease(); serializationResult.Encoding = encoding; DslModeling::DomainXmlSerializerDirectory directory = this.GetDirectory(modelRoot.Store); global::System.IO.MemoryStream newFileContent = new global::System.IO.MemoryStream(); DslModeling::SerializationContext serializationContext = new DslModeling::SerializationContext(directory, fileName, serializationResult); this.InitializeSerializationContext(modelRoot.Partition, serializationContext, false); // MonikerResolver shouldn't be required in Save operation, so not calling SetupMonikerResolver() here. serializationContext.WriteOptionalPropertiesWithDefaultValue = writeOptionalPropertiesWithDefaultValue; global::System.Xml.XmlWriterSettings settings = VModellXTSerializationHelper.Instance.CreateXmlWriterSettings(serializationContext, false, encoding); using (global::System.Xml.XmlWriter writer = global::System.Xml.XmlWriter.Create(newFileContent, settings)) { DslEditorModeling.SerializationOptions options = new DslEditorModeling.SerializationOptions(); //options.SerializationMode = DslEditorModeling.SerializationMode.InternalToString; options.SerializationMode = serializationMode; this.WriteRootElementVModell(serializationContext, modelRoot, writer, options); } return newFileContent; }
/// <summary> /// Save options. /// </summary> /// <param name="filePath">File name to save options to.</param> public void Serialize(string filePath) { System.Text.Encoding encoding = System.Text.Encoding.GetEncoding("ISO-8859-1"); global::System.IO.MemoryStream newFileContent = null; try { newFileContent = new global::System.IO.MemoryStream(); global::System.Xml.XmlTextWriter xmlWriter = new System.Xml.XmlTextWriter(newFileContent, encoding); xmlWriter.Formatting = System.Xml.Formatting.Indented; xmlWriter.WriteStartDocument(); xmlWriter.WriteStartElement("ViewModelOptions"); // write attributes xmlWriter.WriteAttributeString("errorCategoryVisible", this.ErrorCategoryVisible.ToString()); xmlWriter.WriteAttributeString("warningCategoryVisible", this.WarningCategoryVisible.ToString()); xmlWriter.WriteAttributeString("infoCategoryVisible", this.InfoCategoryVisible.ToString()); xmlWriter.WriteAttributeString("filteredCategoryVisible", this.FilteredCategoryVisible.ToString()); SerializeElements(xmlWriter); xmlWriter.WriteEndElement(); xmlWriter.Flush(); if (newFileContent != null) { // Only write the content if there's no error encountered during serialization. global::System.IO.FileStream fileStream = null; try { fileStream = new global::System.IO.FileStream(filePath, global::System.IO.FileMode.Create, global::System.IO.FileAccess.Write, global::System.IO.FileShare.None); using (global::System.IO.BinaryWriter writer = new global::System.IO.BinaryWriter(fileStream, encoding)) { try { writer.Write(newFileContent.ToArray()); } finally { fileStream = null; } } } finally { if (fileStream != null) fileStream.Dispose(); } } } finally { if (newFileContent != null) newFileContent.Dispose(); } }
public virtual void TemporarlySaveModelVModell(DslModeling::SerializationResult serializationResult, global::Tum.VModellXT.VModell modelRoot, string fileName, global::System.Text.Encoding encoding, bool writeOptionalPropertiesWithDefaultValue) { #region Check Parameters if (serializationResult == null) throw new global::System.ArgumentNullException("serializationResult"); if (modelRoot == null) throw new global::System.ArgumentNullException("modelRoot"); if (string.IsNullOrEmpty(fileName)) throw new global::System.ArgumentNullException("fileName"); #endregion if (serializationResult.Failed) return; //DslEditorModeling::DomainModelStore dStore = (DslEditorModeling::DomainModelStore)modelRoot.Store; //if( dStore == null) // throw new global::System.ArgumentNullException("dStore"); //dStore.WaitForWritingLockRelease(); global::System.IO.MemoryStream newFileContent = null; try { newFileContent = new global::System.IO.MemoryStream(); DslModeling::DomainXmlSerializerDirectory directory = this.GetDirectory(modelRoot.Store); DslModeling::SerializationContext serializationContext = new DslModeling::SerializationContext(directory, fileName, serializationResult); this.InitializeSerializationContext(modelRoot.Partition, serializationContext, false); serializationContext.WriteOptionalPropertiesWithDefaultValue = writeOptionalPropertiesWithDefaultValue; global::System.Xml.XmlWriterSettings settings = VModellXTSerializationHelper.Instance.CreateXmlWriterSettings(serializationContext, false, encoding); global::System.Xml.XmlWriter writer = global::System.Xml.XmlWriter.Create(newFileContent, settings); DslEditorModeling::SerializationOptions options = new DslEditorModeling.SerializationOptions(); options.SerializationMode = DslEditorModeling.SerializationMode.Temporarly; this.WriteRootElementVModell(serializationContext, modelRoot, writer, options); writer.Flush(); if (!serializationResult.Failed && newFileContent != null) { // Only write the content if there's no error encountered during serialization. global::System.IO.FileStream fileStream = null; try { fileStream = new global::System.IO.FileStream(fileName, global::System.IO.FileMode.Create, global::System.IO.FileAccess.Write, global::System.IO.FileShare.None); using (global::System.IO.BinaryWriter writerBin = new global::System.IO.BinaryWriter(fileStream, encoding)) { try { writerBin.Write(newFileContent.ToArray()); fileStream.Dispose(); } finally { fileStream = null; } } } finally { if( fileStream != null ) fileStream.Dispose(); } } } finally { if( newFileContent != null ) newFileContent.Dispose(); } }
public static global::Windows.Storage.Streams.IBuffer GetWindowsRuntimeBuffer(this global::System.IO.MemoryStream underlyingStream, int positionInStream, int length) { return(default(global::Windows.Storage.Streams.IBuffer)); }
public void Serialization() { global::System.IO.MemoryStream dst = new global::System.IO.MemoryStream (); global::System.Runtime.Serialization.IFormatter fmtr = new global::System.Runtime.Serialization.Formatters.Binary.BinaryFormatter (); for (int i = 0; i < SerializationCases.Length; ++i) { dst.SetLength (0); DateTimeOffset cur = SerializationCases[i].Input; fmtr.Serialize (dst, cur); String result = BitConverter.ToString (dst.GetBuffer (), 0, (int)dst.Length); Assert.AreEqual (SerializationCases[i].ResultBinaryString, result, "resultToString #" + i); }//for }
/// <summary> /// Constructs a new FlowConnectAction for the given Diagram. /// </summary> public FlowConnectAction(DslDiagrams::Diagram diagram): base(diagram, true) { global::System.Resources.ResourceManager resourceManager = global::Architect.CloudCoreArchitectSubProcessDomainModel.SingletonResourceManager; global::System.Globalization.CultureInfo resourceCulture = global::System.Globalization.CultureInfo.CurrentUICulture; byte[] sourceCursorBytes = (byte[])resourceManager.GetObject("FlowSourceCursor", resourceCulture); using(global::System.IO.MemoryStream sourceCursorStream = new global::System.IO.MemoryStream(sourceCursorBytes)) { this.sourceCursor = new global::System.Windows.Forms.Cursor(sourceCursorStream); } byte[] targetCursorBytes = (byte[])resourceManager.GetObject("FlowTargetCursor", resourceCulture); using(global::System.IO.MemoryStream targetCursorStream = new global::System.IO.MemoryStream(targetCursorBytes)) { this.targetCursor = new global::System.Windows.Forms.Cursor(targetCursorStream); } }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) { dsUserSecurity ds = new dsUserSecurity(); global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); while (schemas.MoveNext()) { schema = (global::System.Xml.Schema.XmlSchema) schemas.Current; s2.SetLength(0); schema.Write(s2); if (s1.Length == s2.Length) { s1.Position = 0; s2.Position = 0; while ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte())) { } if (s1.Position == s1.Length) { return type; } } } } finally { if (s1 != null) { s1.Close(); } if (s2 != null) { s2.Close(); } } } xs.Add(dsSchema); return type; }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) { EMDataSet ds = new EMDataSet(); global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte())); ) { ; } if ((s1.Position == s1.Length)) { return type; } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return type; }
/// <summary> /// Saves the given model root as a in-memory stream. /// This is a helper used by SaveModel() and SaveModelAndDiagram(). When saving the model and the diagram together, we want to make sure that /// both can be saved without error before writing the content to disk, so we serialize the model into a in-memory stream first. /// </summary> /// <param name="serializationResult">Stores serialization result from the save operation.</param> /// <param name="modelRoot">EntityDesignerViewModel instance to be saved.</param> /// <param name="fileName">Name of the file in which the EntityDesignerViewModel instance will be saved.</param> /// <param name="encoding">Encoding to use when saving the EntityDesignerViewModel instance.</param> /// <param name="writeOptionalPropertiesWithDefaultValue">Whether optional properties with default value will be saved.</param> /// <returns>In-memory stream containing the serialized EntityDesignerViewModel instance.</returns> internal virtual global::System.IO.MemoryStream InternalSaveModel(DslModeling::SerializationResult serializationResult, global::Microsoft.Data.Entity.Design.EntityDesigner.ViewModel.EntityDesignerViewModel modelRoot, string fileName, global::System.Text.Encoding encoding, bool writeOptionalPropertiesWithDefaultValue) { #region Check Parameters global::System.Diagnostics.Debug.Assert(serializationResult != null); global::System.Diagnostics.Debug.Assert(modelRoot != null); global::System.Diagnostics.Debug.Assert(!serializationResult.Failed); #endregion serializationResult.Encoding = encoding; DslModeling::DomainXmlSerializerDirectory directory = this.GetDirectory(modelRoot.Store); global::System.IO.MemoryStream newFileContent = new global::System.IO.MemoryStream(); DslModeling::SerializationContext serializationContext = new DslModeling::SerializationContext(directory, fileName, serializationResult); this.InitializeSerializationContext(modelRoot.Partition, serializationContext, false); // MonikerResolver shouldn't be required in Save operation, so not calling SetupMonikerResolver() here. serializationContext.WriteOptionalPropertiesWithDefaultValue = writeOptionalPropertiesWithDefaultValue; global::System.Xml.XmlWriterSettings settings = MicrosoftDataEntityDesignSerializationHelper.Instance.CreateXmlWriterSettings(serializationContext, false, encoding); using (global::System.Xml.XmlWriter writer = global::System.Xml.XmlWriter.Create(newFileContent, settings)) { this.WriteRootElement(serializationContext, modelRoot, writer); } return newFileContent; }