Ejemplo n.º 1
0
        /// <summary>
        /// XMLファイルからパラメータを読み込む
        /// </summary>
        /// <typeparam name="T">
        /// 読み込むパラメータ型.シリアライズ可能なものである必要がある.
        /// </typeparam>
        /// <param name="trg">出力引数.読み込んだデータを設定する対象.</param>
        /// <param name="fn">XMLのファイル名</param>
        static public void LoadFromXmlFile <T>(out T trg, string fn)
        {
            try
            {
                //読み込むファイルを開く
                global::System.IO.FileStream fs = new global::System.IO.FileStream(
                    fn, global::System.IO.FileMode.Open, global::System.IO.FileAccess.Read);

                //XmlSerializerオブジェクトを作成
                global::System.Xml.Serialization.XmlSerializer serializer =
                    new global::System.Xml.Serialization.XmlSerializer(typeof(T));
                //XMLファイルから読み込み、逆シリアル化する
                T obj = (T)serializer.Deserialize(fs);
                //ファイルを閉じる
                fs.Close();

                // modified 2014, Apr 30 by Okuda,
                // Is it OK??
                //trg = DeepClone<T>(obj);
                trg = obj;
            }
            catch
            {
                trg = default(T);
            }
        }
Ejemplo n.º 2
0
 public FileInput(global::System.IO.FileStream stream) : base(((global::haxe.lang.EmptyObject)(global::haxe.lang.EmptyObject.EMPTY)))
 {
     unchecked
     {
         global::sys.io.FileInput.__hx_ctor_sys_io_FileInput(this, stream);
     }
 }
Ejemplo n.º 3
0
        public static global::sys.io.FileInput read(string path, global::haxe.lang.Null <bool> binary)
        {
            bool binary1 = ((!(binary.hasValue)) ? (true) : ((binary).@value));

            global::System.IO.FileStream stream = new global::System.IO.FileStream(((string)(path)), ((global::System.IO.FileMode)(global::System.IO.FileMode.Open)), ((global::System.IO.FileAccess)(global::System.IO.FileAccess.Read)), ((global::System.IO.FileShare)(global::System.IO.FileShare.ReadWrite)));
            return(new global::sys.io.FileInput(((global::System.IO.FileStream)(stream))));
        }
Ejemplo n.º 4
0
        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());
                        }
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public static string GenerateBarCode(string id)
        {
            QRCodeEncoder qrCodeEncoder = new QRCodeEncoder();

            qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;
            qrCodeEncoder.QRCodeScale      = 4;
            // qrCodeEncoder.QRCodeVersion = 4;
            qrCodeEncoder.QRCodeVersion      = 0;
            qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M;
            //System.Drawing.Image image = qrCodeEncoder.Encode("4408810820 深圳-广州 小江");
            global::System.Drawing.Image image = qrCodeEncoder.Encode(id);
            string filename = Guid.NewGuid().ToString() + ".jpg";

            string fileMonthPath = System.Web.HttpContext.Current.Server.MapPath(@"~\UploadFile") + "\\" + DateTime.Now.ToString("yyyyMM");

            if (!System.IO.Directory.Exists(fileMonthPath))
            {
                System.IO.Directory.CreateDirectory(fileMonthPath);
            }

            string filepath = fileMonthPath + "\\" + filename;

            global::System.IO.FileStream fs = new global::System.IO.FileStream(filepath, global::System.IO.FileMode.OpenOrCreate, global::System.IO.FileAccess.Write);
            image.Save(fs, global::System.Drawing.Imaging.ImageFormat.Jpeg);

            fs.Close();
            image.Dispose();
            return(@"../../UploadFile/" + DateTime.Now.ToString("yyyyMM") + "/" + filename);
        }
Ejemplo n.º 6
0
        /// <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();
                }
            }
        }
Ejemplo n.º 7
0
		public static   global::sys.io.FileInput read(string path, global::haxe.lang.Null<bool> binary)
		{
			unchecked 
			{
				bool __temp_binary296 = ( (global::haxe.lang.Runtime.eq((binary).toDynamic(), (default(global::haxe.lang.Null<bool>)).toDynamic())) ? (((bool) (true) )) : (binary.@value) );
				global::System.IO.FileStream stream = new global::System.IO.FileStream(global::haxe.lang.Runtime.toString(path), ((global::System.IO.FileMode) (global::System.IO.FileMode.Open) ), ((global::System.IO.FileAccess) (global::System.IO.FileAccess.Read) ), ((global::System.IO.FileShare) (global::System.IO.FileShare.ReadWrite) ));
				return new global::sys.io.FileInput(((global::System.IO.FileStream) (stream) ));
			}
		}
Ejemplo n.º 8
0
 public static global::sys.io.FileInput read(string path, global::haxe.lang.Null <bool> binary)
 {
     unchecked
     {
         bool __temp_binary296 = ((global::haxe.lang.Runtime.eq((binary).toDynamic(), (default(global::haxe.lang.Null <bool>)).toDynamic())) ? (((bool)(true))) : (binary.@value));
         global::System.IO.FileStream stream = new global::System.IO.FileStream(global::haxe.lang.Runtime.toString(path), ((global::System.IO.FileMode)(global::System.IO.FileMode.Open)), ((global::System.IO.FileAccess)(global::System.IO.FileAccess.Read)), ((global::System.IO.FileShare)(global::System.IO.FileShare.ReadWrite)));
         return(new global::sys.io.FileInput(((global::System.IO.FileStream)(stream))));
     }
 }
Ejemplo n.º 9
0
 private static void @__ctorFileStream11(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__class, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::net.sf.jni4net.utils.JniLocalHandle handle, global::net.sf.jni4net.utils.JniLocalHandle access)
 {
     // (Lsystem/Object;Lsystem/Enum;)V
     // (LMicrosoft/Win32/SafeHandles/SafeFileHandle;LSystem/IO/FileAccess;)V
     global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp);
     try {
     global::System.IO.FileStream @__real = new global::System.IO.FileStream(global::net.sf.jni4net.utils.Convertor.StrongJp2C<global::Microsoft.Win32.SafeHandles.SafeFileHandle>(@__env, handle), global::net.sf.jni4net.utils.Convertor.StrongJp2C<global::System.IO.FileAccess>(@__env, access));
     global::net.sf.jni4net.utils.Convertor.InitProxy(@__env, @__obj, @__real);
     }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);}
 }
Ejemplo n.º 10
0
 private static void @__ctorFileStream10(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__class, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::System.IntPtr handle, global::net.sf.jni4net.utils.JniLocalHandle access, bool ownsHandle, int bufferSize, bool isAsync)
 {
     // (JLsystem/Enum;ZIZ)V
     // (LSystem/IntPtr;LSystem/IO/FileAccess;ZIZ)V
     global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp);
     try {
     global::System.IO.FileStream @__real = new global::System.IO.FileStream(handle, global::net.sf.jni4net.utils.Convertor.StrongJp2C<global::System.IO.FileAccess>(@__env, access), ownsHandle, bufferSize, isAsync);
     global::net.sf.jni4net.utils.Convertor.InitProxy(@__env, @__obj, @__real);
     }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);}
 }
Ejemplo n.º 11
0
 private static void @__ctorFileStream1(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__class, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::net.sf.jni4net.utils.JniLocalHandle path, global::net.sf.jni4net.utils.JniLocalHandle mode, global::net.sf.jni4net.utils.JniLocalHandle access)
 {
     // (Ljava/lang/String;Lsystem/Enum;Lsystem/Enum;)V
     // (LSystem/String;LSystem/IO/FileMode;LSystem/IO/FileAccess;)V
     global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp);
     try {
     global::System.IO.FileStream @__real = new global::System.IO.FileStream(global::net.sf.jni4net.utils.Convertor.StrongJ2CString(@__env, path), global::net.sf.jni4net.utils.Convertor.StrongJp2C<global::System.IO.FileMode>(@__env, mode), global::net.sf.jni4net.utils.Convertor.StrongJp2C<global::System.IO.FileAccess>(@__env, access));
     global::net.sf.jni4net.utils.Convertor.InitProxy(@__env, @__obj, @__real);
     }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);}
 }
Ejemplo n.º 12
0
 private static void @__ctorFileStream5(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__class, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::net.sf.jni4net.utils.JniLocalHandle path, global::net.sf.jni4net.utils.JniLocalHandle mode, global::net.sf.jni4net.utils.JniLocalHandle access, global::net.sf.jni4net.utils.JniLocalHandle share, int bufferSize, bool useAsync)
 {
     // (Ljava/lang/String;Lsystem/Enum;Lsystem/Enum;Lsystem/Enum;IZ)V
     // (LSystem/String;LSystem/IO/FileMode;LSystem/IO/FileAccess;LSystem/IO/FileShare;IZ)V
     global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp);
     try {
         global::System.IO.FileStream @__real = new global::System.IO.FileStream(global::net.sf.jni4net.utils.Convertor.StrongJ2CString(@__env, path), global::net.sf.jni4net.utils.Convertor.StrongJp2C <global::System.IO.FileMode>(@__env, mode), global::net.sf.jni4net.utils.Convertor.StrongJp2C <global::System.IO.FileAccess>(@__env, access), global::net.sf.jni4net.utils.Convertor.StrongJp2C <global::System.IO.FileShare>(@__env, share), bufferSize, useAsync);
         global::net.sf.jni4net.utils.Convertor.InitProxy(@__env, @__obj, @__real);
     }catch (global::System.Exception __ex) { @__env.ThrowExisting(__ex); }
 }
Ejemplo n.º 13
0
 private static void @__ctorFileStream6(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__class, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::net.sf.jni4net.utils.JniLocalHandle path, global::net.sf.jni4net.utils.JniLocalHandle mode, global::net.sf.jni4net.utils.JniLocalHandle rights, global::net.sf.jni4net.utils.JniLocalHandle share, int bufferSize, global::net.sf.jni4net.utils.JniLocalHandle options, global::net.sf.jni4net.utils.JniLocalHandle fileSecurity)
 {
     // (Ljava/lang/String;Lsystem/Enum;Lsystem/Enum;Lsystem/Enum;ILsystem/Enum;Lsystem/Object;)V
     // (LSystem/String;LSystem/IO/FileMode;LSystem/Security/AccessControl/FileSystemRights;LSystem/IO/FileShare;ILSystem/IO/FileOptions;LSystem/Security/AccessControl/FileSecurity;)V
     global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp);
     try {
         global::System.IO.FileStream @__real = new global::System.IO.FileStream(global::net.sf.jni4net.utils.Convertor.StrongJ2CString(@__env, path), global::net.sf.jni4net.utils.Convertor.StrongJp2C <global::System.IO.FileMode>(@__env, mode), global::net.sf.jni4net.utils.Convertor.StrongJp2C <global::System.Security.AccessControl.FileSystemRights>(@__env, rights), global::net.sf.jni4net.utils.Convertor.StrongJp2C <global::System.IO.FileShare>(@__env, share), bufferSize, global::net.sf.jni4net.utils.Convertor.StrongJp2C <global::System.IO.FileOptions>(@__env, options), global::net.sf.jni4net.utils.Convertor.StrongJp2C <global::System.Security.AccessControl.FileSecurity>(@__env, fileSecurity));
         global::net.sf.jni4net.utils.Convertor.InitProxy(@__env, @__obj, @__real);
     }catch (global::System.Exception __ex) { @__env.ThrowExisting(__ex); }
 }
Ejemplo n.º 14
0
 private static void @__ctorFileStream0(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__class, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::net.sf.jni4net.utils.JniLocalHandle path, global::net.sf.jni4net.utils.JniLocalHandle mode)
 {
     // (Ljava/lang/String;Lsystem/Enum;)V
     // (LSystem/String;LSystem/IO/FileMode;)V
     global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp);
     try {
         global::System.IO.FileStream @__real = new global::System.IO.FileStream(global::net.sf.jni4net.utils.Convertor.StrongJ2CString(@__env, path), global::net.sf.jni4net.utils.Convertor.StrongJp2C <global::System.IO.FileMode>(@__env, mode));
         global::net.sf.jni4net.utils.Convertor.InitProxy(@__env, @__obj, @__real);
     }catch (global::System.Exception __ex) { @__env.ThrowExisting(__ex); }
 }
Ejemplo n.º 15
0
 private static void @__ctorFileStream13(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__class, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::net.sf.jni4net.utils.JniLocalHandle handle, global::net.sf.jni4net.utils.JniLocalHandle access, int bufferSize, bool isAsync)
 {
     // (Lsystem/Object;Lsystem/Enum;IZ)V
     // (LMicrosoft/Win32/SafeHandles/SafeFileHandle;LSystem/IO/FileAccess;IZ)V
     global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp);
     try {
         global::System.IO.FileStream @__real = new global::System.IO.FileStream(global::net.sf.jni4net.utils.Convertor.StrongJp2C <global::Microsoft.Win32.SafeHandles.SafeFileHandle>(@__env, handle), global::net.sf.jni4net.utils.Convertor.StrongJp2C <global::System.IO.FileAccess>(@__env, access), bufferSize, isAsync);
         global::net.sf.jni4net.utils.Convertor.InitProxy(@__env, @__obj, @__real);
     }catch (global::System.Exception __ex) { @__env.ThrowExisting(__ex); }
 }
Ejemplo n.º 16
0
 private static void Flush4(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj, bool flushToDisk)
 {
     // (Z)V
     // (Z)V
     global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp);
     try {
         global::System.IO.FileStream @__real = global::net.sf.jni4net.utils.Convertor.StrongJp2C <global::System.IO.FileStream>(@__env, @__obj);
         @__real.Flush(flushToDisk);
     }catch (global::System.Exception __ex) { @__env.ThrowExisting(__ex); }
 }
Ejemplo n.º 17
0
 private static void Unlock8(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj, long position, long length)
 {
     // (JJ)V
     // (JJ)V
     global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp);
     try {
         global::System.IO.FileStream @__real = global::net.sf.jni4net.utils.Convertor.StrongJp2C <global::System.IO.FileStream>(@__env, @__obj);
         @__real.Unlock(position, length);
     }catch (global::System.Exception __ex) { @__env.ThrowExisting(__ex); }
 }
Ejemplo n.º 18
0
 private static void SetAccessControl3(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::net.sf.jni4net.utils.JniLocalHandle fileSecurity)
 {
     // (Lsystem/Object;)V
     // (LSystem/Security/AccessControl/FileSecurity;)V
     global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp);
     try {
         global::System.IO.FileStream @__real = global::net.sf.jni4net.utils.Convertor.StrongJp2C <global::System.IO.FileStream>(@__env, @__obj);
         @__real.SetAccessControl(global::net.sf.jni4net.utils.Convertor.StrongJp2C <global::System.Security.AccessControl.FileSecurity>(@__env, fileSecurity));
     }catch (global::System.Exception __ex) { @__env.ThrowExisting(__ex); }
 }
Ejemplo n.º 19
0
 private static void @__ctorFileStream10(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__class, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::System.IntPtr handle, global::net.sf.jni4net.utils.JniLocalHandle access, bool ownsHandle, int bufferSize, bool isAsync)
 {
     // (JLsystem/Enum;ZIZ)V
     // (LSystem/IntPtr;LSystem/IO/FileAccess;ZIZ)V
     global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp);
     try {
         global::System.IO.FileStream @__real = new global::System.IO.FileStream(handle, global::net.sf.jni4net.utils.Convertor.StrongJp2C <global::System.IO.FileAccess>(@__env, access), ownsHandle, bufferSize, isAsync);
         global::net.sf.jni4net.utils.Convertor.InitProxy(@__env, @__obj, @__real);
     }catch (global::System.Exception __ex) { @__env.ThrowExisting(__ex); }
 }
Ejemplo n.º 20
0
 private static global::net.sf.jni4net.utils.JniHandle SafeFileHandle6(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj)
 {
     // ()Lsystem/Object;
     // ()LMicrosoft/Win32/SafeHandles/SafeFileHandle;
     global::net.sf.jni4net.jni.JNIEnv      @__env    = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp);
     global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle);
     try {
         global::System.IO.FileStream @__real = global::net.sf.jni4net.utils.Convertor.StrongJp2C <global::System.IO.FileStream>(@__env, @__obj);
         @__return = global::net.sf.jni4net.utils.Convertor.StrongC2Jp <global::Microsoft.Win32.SafeHandles.SafeFileHandle>(@__env, @__real.SafeFileHandle);
     }catch (global::System.Exception __ex) { @__env.ThrowExisting(__ex); }
     return(@__return);
 }
Ejemplo n.º 21
0
 private static global::System.IntPtr Handle5(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj)
 {
     // ()J
     // ()LSystem/IntPtr;
     global::net.sf.jni4net.jni.JNIEnv @__env    = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp);
     global::System.IntPtr             @__return = default(global::System.IntPtr);
     try {
         global::System.IO.FileStream @__real = global::net.sf.jni4net.utils.Convertor.StrongJp2C <global::System.IO.FileStream>(@__env, @__obj);
         @__return = ((global::System.IntPtr)(@__real.Handle));
     }catch (global::System.Exception __ex) { @__env.ThrowExisting(__ex); }
     return(@__return);
 }
Ejemplo n.º 22
0
 private static global::net.sf.jni4net.utils.JniHandle Name1(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj)
 {
     // ()Ljava/lang/String;
     // ()LSystem/String;
     global::net.sf.jni4net.jni.JNIEnv      @__env    = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp);
     global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle);
     try {
         global::System.IO.FileStream @__real = global::net.sf.jni4net.utils.Convertor.StrongJp2C <global::System.IO.FileStream>(@__env, @__obj);
         @__return = global::net.sf.jni4net.utils.Convertor.StrongC2JString(@__env, @__real.Name);
     }catch (global::System.Exception __ex) { @__env.ThrowExisting(__ex); }
     return(@__return);
 }
Ejemplo n.º 23
0
 private static global::net.sf.jni4net.utils.JniHandle GetAccessControl2(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj)
 {
     // ()Lsystem/Object;
     // ()LSystem/Security/AccessControl/FileSecurity;
     global::net.sf.jni4net.jni.JNIEnv      @__env    = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp);
     global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle);
     try {
         global::System.IO.FileStream @__real = global::net.sf.jni4net.utils.Convertor.StrongJp2C <global::System.IO.FileStream>(@__env, @__obj);
         @__return = global::net.sf.jni4net.utils.Convertor.StrongC2Jp <global::System.Security.AccessControl.FileSecurity>(@__env, @__real.GetAccessControl());
     }catch (global::System.Exception __ex) { @__env.ThrowExisting(__ex); }
     return(@__return);
 }
        /// <summary>
        /// Saves the diagram.
        /// </summary>
        /// <typeparam name="TModel">The type of the model.</typeparam>
        /// <param name="serializationResult">The serialization result.</param>
        /// <param name="modelRoot">The model root.</param>
        /// <param name="modelFileName">Name of the model file.</param>
        /// <param name="diagram">The diagram.</param>
        /// <param name="diagramFileName">Name of the diagram file.</param>
        /// <param name="encoding">The encoding.</param>
        /// <param name="writeOptionalPropertiesWithDefaultValue">if set to <c>true</c> [write optional properties with default value].</param>
        public void SaveDiagram <TModel>(DslModeling::SerializationResult serializationResult, TModel modelRoot, string modelFileName, ComponentModelDiagram diagram, string diagramFileName, global::System.Text.Encoding encoding, bool writeOptionalPropertiesWithDefaultValue)
            where TModel : ModelElement
        {
            if (serializationResult.Failed)
            {
                return;
            }

            // MonikerResolver shouldn't be required in Save operation, so not calling SetupMonikerResolver() here.

            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);
                    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 (diagramFileContent != null)
                    {
                        IVsQueryEditQuerySave2 scc = ServiceLocator.Instance.GetService <IVsQueryEditQuerySave2>(typeof(SVsQueryEditQuerySave));
                        if (scc != null)
                        {
                            uint result;
                            if (scc.QuerySaveFile(diagramFileName, 0, null, out result) != (int)tagVSQuerySaveResult.QSR_SaveOK)
                            {
                                return;
                            }
                        }
                        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());
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 25
0
        private static bool IsAsync0(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj)
        {
            // ()Z
            // ()Z
            global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp);
            bool @__return = default(bool);

            try {
                global::System.IO.FileStream @__real = global::net.sf.jni4net.utils.Convertor.StrongJp2C <global::System.IO.FileStream>(@__env, @__obj);
                @__return = ((bool)(@__real.IsAsync));
            }catch (global::System.Exception __ex) { @__env.ThrowExisting(__ex); }
            return(@__return);
        }
Ejemplo n.º 26
0
 /// <summary>
 /// パラメータファイルをXMLファイルにシリアライズして書き出す.
 /// </summary>
 /// <typeparam name="T">パラメータ型.シリアライズ可能な型が必要.</typeparam>
 /// <param name="trg">書き出す対象となるパラメータクラスor構造体</param>
 /// <param name="fn">書き出すXMLファイル名</param>
 static public void WriteToXmlFile <T>(T trg, string fn)
 {
     //XmlSerializerオブジェクトを作成
     //オブジェクトの型を指定する
     global::System.Xml.Serialization.XmlSerializer serializer =
         new global::System.Xml.Serialization.XmlSerializer(typeof(T));
     try
     {
         //書き込むファイルを開く
         global::System.IO.FileStream fs = new global::System.IO.FileStream(
             fn, global::System.IO.FileMode.Create);
         //シリアル化し、XMLファイルに保存する
         serializer.Serialize(fs, trg);
         //ファイルを閉じる
         fs.Close();
     }
     catch (Exception)
     {
         global::System.Windows.Forms.MessageBox.Show("設定ファイル" + fn + "が書き込みモードで開けません.", "Error");
     }
 }
Ejemplo n.º 27
0
Archivo: CRC32.cs Proyecto: sinshu/dtf
        /// <summary>
        /// ファイルからCRC32を計算。返し値がCRC32。
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        public UInt32 Update(global::System.IO.FileStream file)
        {
            unchecked
            {
                byte[] buffer   = new byte[BUFFER_SIZE];
                int    readSize = BUFFER_SIZE;

                UInt32 crc = HighBitMask;

                try
                {
                    file.Lock(0, file.Length);

                    int count = file.Read(buffer, 0, readSize);
                    while (count > 0)
                    {
                        for (int i = 0; i < count; i++)
                        {
                            crc = ((crc) >> 8) ^ CRCTable[(buffer[i]) ^ ((crc) & 0x000000FF)];
                        }
                        //	↑は crc = update_crc32(buffer[i], crc); と等価。

                        count = file.Read(buffer, 0, readSize);
                    }

                    file.Unlock(0, file.Length);
                }
                catch (global::System.Exception e)
                {
                    throw e;
                }

                crc          = ~crc;
                LifetimeCRC ^= crc;
                return(crc);
            }
        }
        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();
			}
        }
Ejemplo n.º 29
0
 protected static void __hx_ctor_sys_io_FileInput(global::sys.io.FileInput __hx_this, global::System.IO.FileStream stream)
 {
     global::cs.io.NativeInput.__hx_ctor_cs_io_NativeInput(__hx_this, stream);
 }
Ejemplo n.º 30
0
		public virtual void SaveModelAndDiagram(DslModeling::SerializationResult serializationResult, HostDesignerModel modelRoot, string modelFileName, HostDesignerDiagram 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 = this.InternalSaveDiagram(serializationResult, diagram, diagramFileName, encoding, writeOptionalPropertiesWithDefaultValue))
				{
					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());
								}
							}
						}
					}
				}
			}
		}
Ejemplo n.º 31
0
 private static void @__ctorFileStream6(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__class, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::net.sf.jni4net.utils.JniLocalHandle path, global::net.sf.jni4net.utils.JniLocalHandle mode, global::net.sf.jni4net.utils.JniLocalHandle rights, global::net.sf.jni4net.utils.JniLocalHandle share, int bufferSize, global::net.sf.jni4net.utils.JniLocalHandle options, global::net.sf.jni4net.utils.JniLocalHandle fileSecurity)
 {
     // (Ljava/lang/String;Lsystem/Enum;Lsystem/Enum;Lsystem/Enum;ILsystem/Enum;Lsystem/Object;)V
     // (LSystem/String;LSystem/IO/FileMode;LSystem/Security/AccessControl/FileSystemRights;LSystem/IO/FileShare;ILSystem/IO/FileOptions;LSystem/Security/AccessControl/FileSecurity;)V
     global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp);
     try {
     global::System.IO.FileStream @__real = new global::System.IO.FileStream(global::net.sf.jni4net.utils.Convertor.StrongJ2CString(@__env, path), global::net.sf.jni4net.utils.Convertor.StrongJp2C<global::System.IO.FileMode>(@__env, mode), global::net.sf.jni4net.utils.Convertor.StrongJp2C<global::System.Security.AccessControl.FileSystemRights>(@__env, rights), global::net.sf.jni4net.utils.Convertor.StrongJp2C<global::System.IO.FileShare>(@__env, share), bufferSize, global::net.sf.jni4net.utils.Convertor.StrongJp2C<global::System.IO.FileOptions>(@__env, options), global::net.sf.jni4net.utils.Convertor.StrongJp2C<global::System.Security.AccessControl.FileSecurity>(@__env, fileSecurity));
     global::net.sf.jni4net.utils.Convertor.InitProxy(@__env, @__obj, @__real);
     }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);}
 }
Ejemplo n.º 32
0
        /// <summary>
        /// Load options.
        /// </summary>
        /// <param name="filePath">File name to load options from.</param>
        private void DoDeserialize(string filePath)
        {
            if (System.IO.File.Exists(filePath))
            {
                global::System.IO.FileStream fileStream = null;
                try
                {
                    fileStream = global::System.IO.File.OpenRead(filePath);
                    if (fileStream.Length > 5)
                    {
                        using (global::System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(fileStream))
                        {
                            try
                            {
                                reader.MoveToContent();

                                // read attributes
                                string valueE = reader.GetAttribute("errorCategoryVisible");
                                if (valueE != null)
                                {
                                    this.ErrorCategoryVisible = Boolean.Parse(valueE);
                                }

                                string valueW = reader.GetAttribute("warningCategoryVisible");
                                if (valueW != null)
                                {
                                    this.WarningCategoryVisible = Boolean.Parse(valueW);
                                }

                                string valueI = reader.GetAttribute("infoCategoryVisible");
                                if (valueI != null)
                                {
                                    this.InfoCategoryVisible = Boolean.Parse(valueI);
                                }

                                string valueF = reader.GetAttribute("filteredCategoryVisible");
                                if (valueF != null)
                                {
                                    this.FilteredCategoryVisible = Boolean.Parse(valueF);
                                }

                                while (reader.Read())
                                {
                                    switch (reader.NodeType)
                                    {
                                    case System.Xml.XmlNodeType.Element:
                                    {
                                        DeserializeElement(reader, reader.Name);
                                        break;
                                    }
                                    }
                                }
                            }
                            finally
                            {
                                fileStream = null;
                            }
                        }
                    }
                }
                finally
                {
                    if (fileStream != null)
                    {
                        fileStream.Dispose();
                    }
                }
            }
        }
		public virtual void SaveModel(DslModeling::SerializationResult serializationResult, ExampleModel 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 = this.InternalSaveModel(serializationResult, modelRoot, fileName, encoding, writeOptionalPropertiesWithDefaultValue))
			{
				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());
						}
					}
				}
			}
		}
Ejemplo n.º 34
0
        public MetaModel LoadModel(DslModeling::SerializationResult serializationResult, DslModeling::Partition partition, string fileName, DslModeling::ISchemaResolver schemaResolver, DslValidation::ValidationController validationController, DslModeling::ISerializerLocator serializerLocator, bool bStartT, bool bIsTopMost)
        {
            #region Model
            #region Check Parameters
            if (serializationResult == null)
                throw new global::System.ArgumentNullException("serializationResult");
            if (partition == null)
                throw new global::System.ArgumentNullException("partition");
            if (string.IsNullOrEmpty(fileName))
                throw new global::System.ArgumentNullException("fileName");
            #endregion

            // Ensure there is a transaction for this model to Load in.
            if (!partition.Store.TransactionActive)
            {
                throw new global::System.InvalidOperationException(LanguageDSLDomainModel.SingletonResourceManager.GetString("MissingTransaction"));
            }

            MetaModel modelRoot = null;
            DslModeling::DomainXmlSerializerDirectory directory = this.GetDirectory(partition.Store);
            DslModeling::DomainClassXmlSerializer modelRootSerializer = directory.GetSerializer(MetaModel.DomainClassId);
            global::System.Diagnostics.Debug.Assert(modelRootSerializer != null, "Cannot find serializer for MetaModel!");
            if (modelRootSerializer != null)
            {
                using (global::System.IO.FileStream fileStream = global::System.IO.File.OpenRead(fileName))
                {
                    DslModeling::SerializationContext serializationContext = new DslModeling::SerializationContext(directory, fileStream.Name, serializationResult);
                    this.InitializeSerializationContext(partition, serializationContext, true);
                    DslModeling::TransactionContext transactionContext = new DslModeling::TransactionContext();
                    transactionContext.Add(DslModeling::SerializationContext.TransactionContextKey, serializationContext);

                    DslModeling::Transaction t = null;
                    if (bStartT)
                    {
                        t = partition.Store.TransactionManager.BeginTransaction("Load Model from " + fileName, true, transactionContext);
                    }

                    // Ensure there is some content in the file.  Blank (or almost blank, to account for encoding header bytes, etc.)
                    // files will cause a new root element to be created and returned. 
                    if (fileStream.Length > 5)
                    {
                        try
                        {
                            global::System.Xml.XmlReaderSettings settings = LanguageDSLSerializationHelper.Instance.CreateXmlReaderSettings(serializationContext, false);
                            using (global::System.Xml.XmlReader reader = global::System.Xml.XmlReader.Create(fileStream, settings))
                            {
                                // Attempt to read the encoding.
                                reader.Read(); // Move to the first node - will be the XmlDeclaration if there is one.
                                global::System.Text.Encoding encoding;
                                if (this.TryGetEncoding(reader, out encoding))
                                {
                                    serializationResult.Encoding = encoding;
                                }

                                // Load any additional domain models that are required
                                DslModeling::SerializationUtilities.ResolveDomainModels(reader, serializerLocator, partition.Store);

                                reader.MoveToContent();


                                modelRoot = modelRootSerializer.TryCreateInstance(serializationContext, reader, partition) as MetaModel;
                                if (modelRoot != null && !serializationResult.Failed)
                                {
                                    modelRoot.BaseDirectory = MetaModelLibraryBase.GetBaseDirectory(fileName);
                                    modelRoot.FilePath = fileName;
                                    this.ReadRootElement(serializationContext, modelRoot, reader, schemaResolver);
                                }
                            }

                        }
                        catch (global::System.Xml.XmlException xEx)
                        {
                            DslModeling::SerializationUtilities.AddMessage(
                                serializationContext,
                                DslModeling::SerializationMessageKind.Error,
                                xEx
                            );
                        }
                    }

                    if (modelRoot == null && !serializationResult.Failed)
                    {
                        // create model root if it doesn't exist.
                        modelRoot = this.CreateModelHelper(partition);
                        modelRoot.BaseDirectory = MetaModelLibraryBase.GetBaseDirectory(fileName);
                        modelRoot.FilePath = fileName;
                    }
                    if (bStartT)
                        if (t.IsActive)
                            t.Commit();

                    // Do load-time validation if a ValidationController is provided.
                    if (!serializationResult.Failed && validationController != null)
                    {
                        using (new SerializationValidationObserver(serializationResult, validationController))
                        {
                            validationController.Validate(partition, DslValidation::ValidationCategories.Load);
                        }
                    }
                }
            }

            #endregion

            MetaModel model = modelRoot;
            if (bIsTopMost)
                model.IsTopMost = true;

            #region Diagrams

            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;

            View view = null;
            if (System.IO.File.Exists(fileNameDiagram))
            {
                //DslModeling::DomainXmlSerializerDirectory directory = this.GetDirectory(partition.Store);
                DslModeling::DomainClassXmlSerializer viewSerializer = directory.GetSerializer(View.DomainClassId);
                global::System.Diagnostics.Debug.Assert(viewSerializer != null, "Cannot find serializer for View!");
                if (viewSerializer != null)
                {
                    using (global::System.IO.FileStream fileStream = global::System.IO.File.OpenRead(fileNameDiagram))
                    {
                        DslModeling::SerializationContext serializationContext = new DslModeling::SerializationContext(directory, fileStream.Name, serializationResult);
                        this.InitializeSerializationContext(partition, serializationContext, true);
                        DslModeling::TransactionContext transactionContext = new DslModeling::TransactionContext();
                        transactionContext.Add(DslModeling::SerializationContext.TransactionContextKey, serializationContext);

                        DslModeling::Transaction t = null;
                        if (bStartT)
                            t = partition.Store.TransactionManager.BeginTransaction("Load Model from " + fileNameDiagram, true, transactionContext);

                        // Ensure there is some content in the file.  Blank (or almost blank, to account for encoding header bytes, etc.)
                        // files will cause a new root element to be created and returned. 
                        if (fileStream.Length > 5)
                        {
                            try
                            {
                                global::System.Xml.XmlReaderSettings settings = LanguageDSLSerializationHelper.Instance.CreateXmlReaderSettings(serializationContext, false);
                                using (global::System.Xml.XmlReader reader = global::System.Xml.XmlReader.Create(fileStream, settings))
                                {
                                    // Attempt to read the encoding.
                                    reader.Read(); // Move to the first node - will be the XmlDeclaration if there is one.
                                    global::System.Text.Encoding encoding;
                                    if (this.TryGetEncoding(reader, out encoding))
                                    {
                                        serializationResult.Encoding = encoding;
                                    }
                                    reader.MoveToContent();

                                    view = viewSerializer.TryCreateInstance(serializationContext, reader, partition) as View;
                                    if (view != null && !serializationResult.Failed)
                                    {
                                        // Use a validating reader if possible
                                        viewSerializer.Read(serializationContext, view, reader);

                                        model.View = view;
                                    }
                                }
                            }

                            catch (global::System.Xml.XmlException xEx)
                            {
                                DslModeling::SerializationUtilities.AddMessage(
                                    serializationContext,
                                    DslModeling::SerializationMessageKind.Error,
                                    xEx
                                );
                            }
                        }

                        if (bStartT)
                            if (t.IsActive)
                                t.Commit();

                    }
                }
            }
            #endregion

            //if( bIsTopMost )
            SerializationPostProcessor.PostProcessModelLoad(model);

            return model;
        }
        public virtual void SaveModelAndDiagrams(DslModeling::SerializationResult serializationResult, ModelRoot modelRoot, string modelFileName, DslDiagrams::Diagram[] diagrams, string diagramsFileName, 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 (diagrams == null)
            {
                throw new global::System.ArgumentNullException("diagrams");
            }
            if (string.IsNullOrEmpty(diagramsFileName))
            {
                throw new global::System.ArgumentNullException("diagramsFileName");
            }
            #endregion

            if (serializationResult.Failed)
            {
                return;
            }

            // Save the model file first
            var modelFileContent = this.InternalSaveModel(serializationResult, modelRoot, modelFileName, encoding, writeOptionalPropertiesWithDefaultValue);
            if (serializationResult.Failed)
            {
                modelFileContent.Close();
                return;
            }

            var memoryStreamDictionary = new Dictionary <global::System.IO.MemoryStream, string>();
            foreach (var diagram in diagrams)
            {
                if (string.IsNullOrEmpty(diagram.Name))
                {
                    throw new ArgumentException("Each diagram must have a name", "diagrams");
                }
                memoryStreamDictionary.Add(this.InternalSaveDiagram(serializationResult, diagram, diagramsFileName, encoding, writeOptionalPropertiesWithDefaultValue), diagram.Name);
                if (serializationResult.Failed)
                {
                    modelFileContent.Close();
                    memoryStreamDictionary.Keys.ToList <global::System.IO.MemoryStream>().ForEach(memoryStream => memoryStream.Close());
                    return;
                }
            }

            // 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());
                    }
                }
            }

            WriteDiagramFile(diagramsFileName, memoryStreamDictionary);
        }
Ejemplo n.º 36
0
 public static void __hx_ctor_sys_io_FileOutput(global::sys.io.FileOutput __hx_this, global::System.IO.FileStream stream)
 {
     global::cs.io.NativeOutput.__hx_ctor_cs_io_NativeOutput(__hx_this, stream);
 }
Ejemplo n.º 37
0
 public static void __hx_ctor_sys_io_FileInput(global::sys.io.FileInput __temp_me298, global::System.IO.FileStream stream)
 {
     unchecked
     {
         global::cs.io.NativeInput.__hx_ctor_cs_io_NativeInput(__temp_me298, stream);
     }
 }
Ejemplo n.º 38
0
		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());
								}
							}
						}
					}
				}
			}
		}
		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());
						}
					}
				}
			}
		}
        /// <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();
            }
        }
        /// <summary>
        /// Loads the diagram.
        /// </summary>
        /// <typeparam name="TModel">The type of the model.</typeparam>
        /// <typeparam name="TDiagram">The type of the diagram.</typeparam>
        /// <param name="serializationResult">The serialization result.</param>
        /// <param name="modelRoot">The model root.</param>
        /// <param name="diagramFileName">Name of the diagram file.</param>
        /// <param name="schemaResolver">The schema resolver.</param>
        /// <param name="diagramDomainId">The diagram domain id.</param>
        /// <param name="callback">The callback.</param>
        public void LoadDiagram <TModel, TDiagram>(DslModeling::SerializationResult serializationResult, TModel modelRoot, string diagramFileName, DslModeling::ISchemaResolver schemaResolver, System.Guid diagramDomainId, CreateDiagramHandler callback)
            where TModel : ModelElement
            where TDiagram : ComponentModelDiagram
        {
            Partition diagramPartition = modelRoot.Store.DefaultPartition;

            // Ensure there is an outer transaction spanning both model and diagram load, so moniker resolution works properly.
            if (!diagramPartition.Store.TransactionActive)
            {
                throw new global::System.InvalidOperationException(global::DSLFactory.Candle.SystemModel.CandleDomainModel.SingletonResourceManager.GetString("MissingTransaction"));
            }

            ComponentModelDiagram diagram = null;
            DslModeling::DomainClassXmlSerializer diagramSerializer = this.Directory.GetSerializer(diagramDomainId);

            global::System.Diagnostics.Debug.Assert(diagramSerializer != null, "Cannot find serializer for SystemModelDiagram");
            if (diagramSerializer != null)
            {
                if (!global::System.IO.File.Exists(diagramFileName))
                {
                    // missing diagram file indicates we should create a new diagram.
                    diagram = callback(diagramPartition);
                }
                else
                {
                    using (global::System.IO.FileStream fileStream = global::System.IO.File.OpenRead(diagramFileName))
                    {
                        DslModeling::SerializationContext serializationContext = new DslModeling::SerializationContext(this.Directory, fileStream.Name, serializationResult);

                        using (DslModeling::Transaction t = diagramPartition.Store.TransactionManager.BeginTransaction("LoadDiagram", true))
                        {
                            // Ensure there is some content in the file. Blank (or almost blank, to account for encoding header bytes, etc.)
                            // files will cause a new diagram to be created and returned
                            if (fileStream.Length > 5)
                            {
                                global::System.Xml.XmlReaderSettings settings = new global::System.Xml.XmlReaderSettings();
                                try
                                {
                                    using (global::System.Xml.XmlReader reader = global::System.Xml.XmlReader.Create(fileStream, settings))
                                    {
                                        reader.MoveToContent();
                                        diagram = diagramSerializer.TryCreateInstance(serializationContext, reader, diagramPartition) as ComponentModelDiagram;
                                        if (diagram != null)
                                        {
                                            // Note: the actual instance we get back from TryCreateInstance() can be of a derived type of SystemModelDiagram,
                                            // so we need to find the correct serializer instance to deserialize the element properly.
                                            DslModeling::DomainClassXmlSerializer instanceSerializer = this.Directory.GetSerializer(diagram.GetDomainClass().Id);
                                            global::System.Diagnostics.Debug.Assert(instanceSerializer != null, "Cannot find serializer for " + diagram.GetDomainClass().Name + "!");
                                            instanceSerializer.ReadRootElement(serializationContext, diagram, reader, schemaResolver);
                                        }
                                    }
                                }
                                catch (global::System.Xml.XmlException xEx)
                                {
                                    DslModeling::SerializationUtilities.AddMessage(
                                        serializationContext,
                                        DslModeling::SerializationMessageKind.Error,
                                        xEx
                                        );
                                }
                                if (serializationResult.Failed)
                                {
                                    // Serialization error encountered, rollback the transaction.
                                    diagram = null;
                                    t.Rollback();
                                }
                            }

                            if (diagram == null && !serializationResult.Failed)
                            {
                                // Create diagram if it doesn't exist
                                diagram = CreateDiagramHelper(diagramPartition, modelRoot);
                            }

                            if (t.IsActive)
                            {
                                t.Commit();
                            }
                        } // End inner Tx
                    }
                }

                if (diagram != null)
                {
                    diagram.ModelElement = modelRoot;
                }
            }
        }