예제 #1
0
        /// <summary>
        /// Gets property bindings, including those set by styles.
        /// </summary>
        public List <PropertyBinding> GetPropertyBindingsWithStyle()
        {
            var propertyBindings = new List <PropertyBinding>();

            propertyBindings.AddRange(PropertyExpressions.OfType <PropertyBinding>());

            var stylePropertyBindings = ContentObjectModel.GetViewObjectStylePropertyBindings(Name);

            propertyBindings.AddRange(stylePropertyBindings);

            return(propertyBindings);
        }
예제 #2
0
        public List <PropertyAssignment> GetAllActionAssignmentsWithStyle()
        {
            var propertyAssignments = new List <PropertyAssignment>();

            propertyAssignments.AddRange(PropertyExpressions.OfType <PropertyAssignment>());

            var stylePropertyAssignments = ContentObjectModel.GetViewObjectStylePropertyAssignments(Name);

            propertyAssignments.AddRange(stylePropertyAssignments);

            var viewDeclarations = GetViewDeclarations(false);

            foreach (var viewDeclaration in viewDeclarations)
            {
                propertyAssignments.AddRange(viewDeclaration.Declaration.GetPropertyAssignmentsWithStyle(out var styleMissing));
            }

            return(propertyAssignments.Where(x => x.PropertyDeclarationInfo != null && x.PropertyDeclarationInfo.Declaration.DeclarationType == PropertyDeclarationType.Action).ToList());
        }
예제 #3
0
        /// <summary>
        /// Loads asset object, creates new one if it doesn't exist.
        /// </summary>
        public UnityAssetObject LoadUnityAssetObject(string assetName, string path, Type type)
        {
            var asset = AssetObjects.FirstOrDefault(x => x.Name.IEquals(assetName) && x.Type.Name.IEquals(type.Name));

            if (asset == null)
            {
                var assetType = ContentObjectModel.GetInstance().LoadAssetType(type, true);
                asset = new UnityAssetObject {
                    Name = assetName, Type = assetType, Path = path, IsResource = IsResource, AssetBundleName = Name
                };
                AssetObjects.Add(asset);
            }

            // path within bundle can change
            asset.Path = path;
            string relativePath = asset.Path.Substring(FullPath.Length - 1);

            asset.RelativePath = relativePath.Substring(0, relativePath.LastIndexOf(assetName));
            return(asset);
        }
예제 #4
0
        /// <summary>
        /// Gets property assignments, including those set by styles.
        /// </summary>
        public List <PropertyAssignment> GetPropertyAssignmentsWithStyle(out bool styleMissing)
        {
            var propertyAssignments = new List <PropertyAssignment>();

            styleMissing = false;

            if (!String.IsNullOrEmpty(Style))
            {
                var stylePropertyAssignments = ContentObjectModel.GetStylePropertyAssignments(ViewName, Style, out styleMissing);
                propertyAssignments.AddRange(stylePropertyAssignments);
            }

            propertyAssignments.AddRange(PropertyAssignments);
            if (propertyAssignments.Count <= 0)
            {
                return(propertyAssignments);
            }

            return(propertyAssignments.GroupBy(x => x.StateName + ":" + x.PropertyName).Select(y => y.LastOrDefault()).ToList());
        }
예제 #5
0
        /// <summary>
        /// Gets property bindings, including those set by styles.
        /// </summary>
        public List <PropertyBinding> GetPropertyBindingsWithStyle(out bool styleMissing)
        {
            var propertyBindings = new List <PropertyBinding>();

            styleMissing = false;

            if (!String.IsNullOrEmpty(Style))
            {
                var stylePropertyBindings = ContentObjectModel.GetStylePropertyBindings(ViewName, Style);
                propertyBindings.AddRange(stylePropertyBindings);
                styleMissing = !stylePropertyBindings.Any();
            }

            propertyBindings.AddRange(PropertyBindings);
            if (propertyBindings.Count <= 0)
            {
                return(propertyBindings);
            }

            return(propertyBindings.GroupBy(x => x.PropertyName).Select(y => y.LastOrDefault()).ToList());
        }
예제 #6
0
        /// <summary>
        /// Loads object model if it's not already loaded.
        /// </summary>
        private static void LoadObjectModel()
        {
            // check if file exist
            var modelFilePath = GetContentObjectModelFilePath();

            if (!File.Exists(modelFilePath))
            {
                _contentObjectModel             = new ContentObjectModel();
                _contentObjectModel.NeedRebuild = true;
                return;
            }

            // deserialize file
            lock (_fileLock)
            {
                using (var file = File.OpenRead(modelFilePath))
                {
                    //Debug.Log("Deserializing " + modelFilePath);
                    try
                    {
                        _contentObjectModel = Serializer.Deserialize <ContentObjectModel>(file);
                    }
                    catch (Exception e)
                    {
                        Debug.LogException(e);
                        Debug.LogError(String.Format("#Delight# Failed to deserialize content object model file \"{0}\". Creating new content model.", ContentObjectModelFile));
                        _contentObjectModel             = new ContentObjectModel();
                        _contentObjectModel.NeedRebuild = true;
                        return;
                    }
                    finally
                    {
                        file.Close();
                    }
                }
            }
        }