Exemple #1
0
 public void InitializeComponent() {
     if ((this._contentLoaded == true)) {
         return;
     }
     this._contentLoaded = true;
     string resourceName = this.FindResource();
     System.IO.Stream initializeXaml = typeof(状态机流程).Assembly.GetManifestResourceStream(resourceName);
     System.Xml.XmlReader xmlReader = null;
     System.Xaml.XamlReader reader = null;
     System.Xaml.XamlObjectWriter objectWriter = null;
     try {
         System.Xaml.XamlSchemaContext schemaContext = XamlStaticHelperNamespace._XamlStaticHelper.SchemaContext;
         xmlReader = System.Xml.XmlReader.Create(initializeXaml);
         System.Xaml.XamlXmlReaderSettings readerSettings = new System.Xaml.XamlXmlReaderSettings();
         readerSettings.LocalAssembly = System.Reflection.Assembly.GetExecutingAssembly();
         readerSettings.AllowProtectedMembersOnRoot = true;
         reader = new System.Xaml.XamlXmlReader(xmlReader, schemaContext, readerSettings);
         System.Xaml.XamlObjectWriterSettings writerSettings = new System.Xaml.XamlObjectWriterSettings();
         writerSettings.RootObjectInstance = this;
         writerSettings.AccessLevel = System.Xaml.Permissions.XamlAccessLevel.PrivateAccessTo(typeof(状态机流程));
         objectWriter = new System.Xaml.XamlObjectWriter(schemaContext, writerSettings);
         System.Xaml.XamlServices.Transform(reader, objectWriter);
     }
     finally {
         if ((xmlReader != null)) {
             ((System.IDisposable)(xmlReader)).Dispose();
         }
         if ((reader != null)) {
             ((System.IDisposable)(reader)).Dispose();
         }
         if ((objectWriter != null)) {
             ((System.IDisposable)(objectWriter)).Dispose();
         }
     }
 }
        public void InitializeComponent()
        {
            if ((this._contentLoaded == true))
            {
                return;
            }
            this._contentLoaded = true;
            bool isInitialized = false;

            this.BeforeInitializeComponent(ref isInitialized);
            if ((isInitialized == true))
            {
                this.AfterInitializeComponent();
                return;
            }
            string resourceName = this.FindResource();

            System.IO.Stream             initializeXaml = typeof(Divide).Assembly.GetManifestResourceStream(resourceName);
            System.Xml.XmlReader         xmlReader      = null;
            System.Xaml.XamlReader       reader         = null;
            System.Xaml.XamlObjectWriter objectWriter   = null;
            try {
                System.Xaml.XamlSchemaContext schemaContext = XamlStaticHelperNamespace._XamlStaticHelper.SchemaContext;
                xmlReader = System.Xml.XmlReader.Create(initializeXaml);
                System.Xaml.XamlXmlReaderSettings readerSettings = new System.Xaml.XamlXmlReaderSettings();
                readerSettings.LocalAssembly = System.Reflection.Assembly.GetExecutingAssembly();
                readerSettings.AllowProtectedMembersOnRoot = true;
                reader = new System.Xaml.XamlXmlReader(xmlReader, schemaContext, readerSettings);
                System.Xaml.XamlObjectWriterSettings writerSettings = new System.Xaml.XamlObjectWriterSettings();
                writerSettings.RootObjectInstance = this;
                writerSettings.AccessLevel        = System.Xaml.Permissions.XamlAccessLevel.PrivateAccessTo(typeof(Divide));
                objectWriter = new System.Xaml.XamlObjectWriter(schemaContext, writerSettings);
                System.Xaml.XamlServices.Transform(reader, objectWriter);
            }
            finally {
                if ((xmlReader != null))
                {
                    ((System.IDisposable)(xmlReader)).Dispose();
                }
                if ((reader != null))
                {
                    ((System.IDisposable)(reader)).Dispose();
                }
                if ((objectWriter != null))
                {
                    ((System.IDisposable)(objectWriter)).Dispose();
                }
            }
            this.AfterInitializeComponent();
        }
Exemple #3
0
        public System.Activities.Activity Activity()
        {
            if (string.IsNullOrEmpty(Xaml))
            {
                return(null);
            }
            if (_activity != null)
            {
                return(_activity);
            }
            var activitySettings = new System.Activities.XamlIntegration.ActivityXamlServicesSettings
            {
                CompileExpressions = true
            };

            if (!string.IsNullOrEmpty(culture))
            {
                try
                {
                    _activity = Task.Run(() =>
                    {
                        System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(culture);
                        var xamlReaderSettings = new System.Xaml.XamlXmlReaderSettings {
                            LocalAssembly = typeof(Workflow).Assembly
                        };
                        var xamlReader = new System.Xaml.XamlXmlReader(new System.IO.StringReader(Xaml), xamlReaderSettings);
                        return(System.Activities.XamlIntegration.ActivityXamlServices.Load(xamlReader, activitySettings));
                    }).Result;
                }
                catch (Exception ex)
                {
                    while (ex.InnerException != null)
                    {
                        ex = ex.InnerException;
                    }
                    throw ex;
                }
            }
            else
            {
                var xamlReaderSettings = new System.Xaml.XamlXmlReaderSettings {
                    LocalAssembly = typeof(Workflow).Assembly
                };
                var xamlReader = new System.Xaml.XamlXmlReader(new System.IO.StringReader(Xaml), xamlReaderSettings);
                _activity = System.Activities.XamlIntegration.ActivityXamlServices.Load(xamlReader, activitySettings);
            }
            return(_activity);
        }
Exemple #4
0
        static Workbenches()
        {
            var asm = System.Reflection.Assembly.GetExecutingAssembly();

            WorkbenchInfo[] workbenchInfos;

            using (var stream = asm.GetManifestResourceStream("Dwarrowdelf.Game.Workbenches.xaml"))
            {
                var settings = new System.Xaml.XamlXmlReaderSettings()
                {
                    LocalAssembly = asm,
                };
                using (var reader = new System.Xaml.XamlXmlReader(stream, settings))
                    workbenchInfos = (WorkbenchInfo[])System.Xaml.XamlServices.Load(reader);
            }

            s_workbenchInfos = new Dictionary <ItemID, WorkbenchInfo>(workbenchInfos.Length);

            foreach (var workbench in workbenchInfos)
            {
                if (s_workbenchInfos.ContainsKey(workbench.WorkbenchID))
                {
                    throw new Exception();
                }

                foreach (var bi in workbench.BuildableItems)
                {
                    if (String.IsNullOrEmpty(bi.Key))
                    {
                        bi.Key = bi.ItemID.ToString();
                    }

                    bi.FullKey = String.Format("{0},{1}", workbench.WorkbenchID, bi.Key);
                }

                // verify BuildableItem key uniqueness
                var grouped = workbench.BuildableItems.GroupBy(bi => bi.Key);
                foreach (var g in grouped)
                {
                    if (g.Count() != 1)
                    {
                        throw new Exception();
                    }
                }

                s_workbenchInfos[workbench.WorkbenchID] = workbench;
            }
        }
Exemple #5
0
        static Materials()
        {
            var asm = System.Reflection.Assembly.GetExecutingAssembly();

            MaterialInfo[] materials;

            using (var stream = asm.GetManifestResourceStream("Dwarrowdelf.Game.Materials.xaml"))
            {
                var settings = new System.Xaml.XamlXmlReaderSettings()
                {
                    LocalAssembly = asm,
                };
                using (var reader = new System.Xaml.XamlXmlReader(stream, settings))
                    materials = (MaterialInfo[])System.Xaml.XamlServices.Load(reader);
            }

            var max = materials.Max(m => (int)m.ID);

            s_materials = new MaterialInfo[max + 1];

            foreach (var item in materials)
            {
                if (s_materials[(int)item.ID] != null)
                {
                    throw new Exception("Duplicate entry");
                }

                if (item.Name == null)
                {
                    item.Name = item.ID.ToString().ToLowerInvariant();
                }

                if (item.Adjective == null)
                {
                    item.Adjective = item.Name;
                }

                s_materials[(int)item.ID] = item;
            }

            s_materials[0] = new MaterialInfo()
            {
                ID       = MaterialID.Undefined,
                Name     = "<undefined>",
                Category = MaterialCategory.Undefined,
                Color    = GameColor.None,
            };
        }
Exemple #6
0
        //第一步以后,后续所有流程步骤的入口
        private static void ApproveOp(bool op, Guid workflowId, HzWorkFlowContext hzwfContext)
        {
            System.Xaml.XamlXmlReaderSettings st = new System.Xaml.XamlXmlReaderSettings()
            {
                LocalAssembly = System.Reflection.Assembly.GetExecutingAssembly()
            };
            System.Activities.Activity act = null;
            using (var reader = new System.Xaml.XamlXmlReader(workflowName, st)) {
                act = System.Activities.XamlIntegration.ActivityXamlServices.Load(reader);
            }
            var wfa = new System.Activities.WorkflowApplication(act);

            ConfigWfa(wfa);
            wfa.Load(workflowId);
            wfa.ResumeBookmark(bookmark, op);
        }
        public void Load(Uri symbolInfoUri)
        {
            m_drawingMap = new Dictionary<SymbolID, Dictionary<GameColor, Drawing>>();

            var resInfo = Application.GetRemoteStream(symbolInfoUri);

            var settings = new System.Xaml.XamlXmlReaderSettings()
            {
                LocalAssembly = System.Reflection.Assembly.GetCallingAssembly(),
            };

            using (var reader = new System.Xaml.XamlXmlReader(resInfo.Stream, settings))
                m_symbolSet = (Symbols.SymbolSet)System.Xaml.XamlServices.Load(reader);

            if (m_symbolSet.Drawings != null)
                m_drawingCache = new DrawingCache(new Uri(m_symbolSet.Drawings, UriKind.Relative));
        }
        public void Load(Uri symbolInfoUri)
        {
            m_drawingMap = new Dictionary <SymbolID, Dictionary <GameColor, Drawing> >();

            var resInfo = Application.GetRemoteStream(symbolInfoUri);

            var settings = new System.Xaml.XamlXmlReaderSettings()
            {
                LocalAssembly = System.Reflection.Assembly.GetCallingAssembly(),
            };

            using (var reader = new System.Xaml.XamlXmlReader(resInfo.Stream, settings))
                m_symbolSet = (Symbols.SymbolSet)System.Xaml.XamlServices.Load(reader);

            if (m_symbolSet.Drawings != null)
            {
                m_drawingCache = new DrawingCache(new Uri(m_symbolSet.Drawings, UriKind.Relative));
            }
        }
Exemple #9
0
        public System.Activities.Activity Activity()
        {
            if (string.IsNullOrEmpty(Xaml))
            {
                return(null);
            }
            if (_activity != null)
            {
                return(_activity);
            }
            var activitySettings = new System.Activities.XamlIntegration.ActivityXamlServicesSettings
            {
                CompileExpressions = true
            };
            var xamlReaderSettings = new System.Xaml.XamlXmlReaderSettings {
                LocalAssembly = typeof(Workflow).Assembly
            };
            var xamlReader = new System.Xaml.XamlXmlReader(new System.IO.StringReader(Xaml), xamlReaderSettings);

            _activity = System.Activities.XamlIntegration.ActivityXamlServices.Load(xamlReader, activitySettings);
            return(_activity);
        }
Exemple #10
0
        static Workbenches()
        {
            var asm = System.Reflection.Assembly.GetExecutingAssembly();

            WorkbenchInfo[] workbenchInfos;

            using (var stream = asm.GetManifestResourceStream("Dwarrowdelf.Game.Workbenches.xaml"))
            {
                var settings = new System.Xaml.XamlXmlReaderSettings()
                {
                    LocalAssembly = asm,
                };
                using (var reader = new System.Xaml.XamlXmlReader(stream, settings))
                    workbenchInfos = (WorkbenchInfo[])System.Xaml.XamlServices.Load(reader);
            }

            s_workbenchInfos = new Dictionary<ItemID, WorkbenchInfo>(workbenchInfos.Length);

            foreach (var workbench in workbenchInfos)
            {
                if (s_workbenchInfos.ContainsKey(workbench.WorkbenchID))
                    throw new Exception();

                foreach (var bi in workbench.BuildableItems)
                {
                    if (String.IsNullOrEmpty(bi.Key))
                        bi.Key = bi.ItemID.ToString();

                    bi.FullKey = String.Format("{0},{1}", workbench.WorkbenchID, bi.Key);
                }

                // verify BuildableItem key uniqueness
                var grouped = workbench.BuildableItems.GroupBy(bi => bi.Key);
                foreach (var g in grouped)
                    if (g.Count() != 1)
                        throw new Exception();

                s_workbenchInfos[workbench.WorkbenchID] = workbench;
            }
        }
Exemple #11
0
        static Terrains()
        {
            var asm = System.Reflection.Assembly.GetExecutingAssembly();

            TerrainInfo[] terrains;

            using (var stream = asm.GetManifestResourceStream("Dwarrowdelf.Game.Data.Terrains.xaml"))
            {
                var settings = new System.Xaml.XamlXmlReaderSettings()
                {
                    LocalAssembly = asm,
                };
                using (var reader = new System.Xaml.XamlXmlReader(stream, settings))
                    terrains = (TerrainInfo[])System.Xaml.XamlServices.Load(reader);
            }

            var max = terrains.Max(m => (int)m.ID);
            s_terrains = new TerrainInfo[max + 1];

            foreach (var item in terrains)
            {
                if (s_terrains[(int)item.ID] != null)
                    throw new Exception("Duplicate entry");

                if (item.Name == null)
                    item.Name = item.ID.ToString().ToLowerInvariant();

                s_terrains[(int)item.ID] = item;
            }

            s_terrains[0] = new TerrainInfo()
            {
                ID = TerrainID.Undefined,
                Name = "<undefined>",
            };
        }
Exemple #12
0
        static Materials()
        {
            var asm = System.Reflection.Assembly.GetExecutingAssembly();

            MaterialInfo[] materials;

            using (var stream = asm.GetManifestResourceStream("Dwarrowdelf.Game.Data.Materials.xaml"))
            {
                var settings = new System.Xaml.XamlXmlReaderSettings()
                {
                    LocalAssembly = asm,
                };
                using (var reader = new System.Xaml.XamlXmlReader(stream, settings))
                    materials = (MaterialInfo[])System.Xaml.XamlServices.Load(reader);
            }

            var max = materials.Max(m => (int)m.ID);
            s_materials = new MaterialInfo[max + 1];

            foreach (var item in materials)
            {
                if (s_materials[(int)item.ID] != null)
                    throw new Exception("Duplicate entry");

                if (item.Name == null)
                    item.Name = item.ID.ToString().ToLowerInvariant();

                if (item.Adjective == null)
                    item.Adjective = item.Name;

                s_materials[(int)item.ID] = item;
            }

            s_materials[0] = new MaterialInfo()
            {
                ID = MaterialID.Undefined,
                Name = "<undefined>",
                Category = MaterialCategory.Undefined,
                Color = GameColor.None,
            };
        }
Exemple #13
0
        static Livings()
        {
            var asm = System.Reflection.Assembly.GetExecutingAssembly();

            LivingInfo[] livings;

            using (var stream = asm.GetManifestResourceStream("Dwarrowdelf.Game.Livings.xaml"))
            {
                var settings = new System.Xaml.XamlXmlReaderSettings()
                {
                    LocalAssembly = asm,
                };
                using (var reader = new System.Xaml.XamlXmlReader(stream, settings))
                    livings = (LivingInfo[])System.Xaml.XamlServices.Load(reader);
            }

            var max = livings.Max(i => (int)i.ID);
            s_livings = new LivingInfo[max + 1];

            foreach (var living in livings)
            {
                if (s_livings[(int)living.ID] != null)
                    throw new Exception();

                if (living.Name == null)
                    living.Name = living.ID.ToString().ToLowerInvariant();

                s_livings[(int)living.ID] = living;
            }
        }
Exemple #14
0
        static Items()
        {
            var asm = System.Reflection.Assembly.GetExecutingAssembly();

            ItemInfo[] items;

            using (var stream = asm.GetManifestResourceStream("Dwarrowdelf.Game.Data.Items.xaml"))
            {
                var settings = new System.Xaml.XamlXmlReaderSettings()
                {
                    LocalAssembly = asm,
                };
                using (var reader = new System.Xaml.XamlXmlReader(stream, settings))
                    items = (ItemInfo[])System.Xaml.XamlServices.Load(reader);
            }

            var max = items.Max(i => (int)i.ID);
            s_items = new ItemInfo[max + 1];

            foreach (var item in items)
            {
                if (s_items[(int)item.ID] != null)
                    throw new Exception();

                if (item.Name == null)
                    item.Name = item.ID.ToString().ToLowerInvariant();

                s_items[(int)item.ID] = item;
            }
        }