Esempio n. 1
0
        public EditorSessionFrame(EditorSession editorSession)
        {
            EditorSession = editorSession;

            EditorSession.OnChanged += () =>
            {
                HasUnsavedChanges = true;
            };

            var feature = EditorSession.GetOrCreateFeature <FramedEditorSessionFeature>();

            feature.Frame = this;
        }
Esempio n. 2
0
        public EditorSessionFrame(IResource resource)
        {
            Resource = resource;

            JObject editorTarget;

            using (var editorTargetData = Resource.Content.LoadStream())
                using (var sr = new StreamReader(editorTargetData))
                    using (var reader = new JsonTextReader(sr))
                    {
                        editorTarget = JObject.Load(reader);
                    }

            var manifest = BehaviourManifest.CreateFromAppDomain(AppDomain.CurrentDomain);

            string typeName = null;

            if (Resource.Tags.Contains("type-building"))
            {
                typeName = "BuildingTemplate";
            }
            else if (Resource.Tags.Contains("type-resource"))
            {
                typeName = "ResourceTemplate";
            }
            else if (Resource.Tags.Contains("type-buildingpack"))
            {
                typeName = "BuildingPackTemplate";
            }
            else if (Resource.Tags.Contains("gamerules"))
            {
                typeName = "GameRulesTemplate";
            }
            else if (Resource.Tags.Contains("type-project"))
            {
                typeName = "ProjectModel";
            }
            else if (Resource.Tags.Contains("type-skill"))
            {
                typeName = "SkillModel";
            }
            else if (Resource.Tags.Contains("type-category"))
            {
                typeName = "ProjectCategoryModel";
            }
            else if (Resource.Tags.Contains("type-education"))
            {
                typeName = "EducationalInstitutionModel";
            }
            else if (Resource.Tags.Contains("type-company"))
            {
                typeName = "CompanyModel";
            }
            else if (Resource.Tags.Contains("type-category"))
            {
                typeName = "ProjectCategoryModel";
            }
            else
            {
                typeName = "ProceduralItemTemplate";
            }

            EditorSession = new EditorSession(manifest, editorTarget, typeName, serializer);

            EditorSession.OnChanged += () =>
            {
                HasUnsavedChanges = true;
            };

            var feature = EditorSession.GetOrCreateFeature <FramedEditorSessionFeature>();

            feature.Frame = this;
        }