Exemplo n.º 1
0
        public void Init(IContentReference contentReference)
        {
            this.contentReference = contentReference;

            //Immediatly increment the instance count
            contentReference.IncrementReferences();
        }
Exemplo n.º 2
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            IContentReference result = (IContentReference)this.getGlobalObject <FastActivator>().createInstance(objectType);

            if (reader.TokenType == JsonToken.Null)
            {
                return(result);
            }

            // Load JObject from stream
            JObject jo         = JObject.Load(reader);
            JToken  guid_token = jo.GetValue(nameof(BaseContent.guid));

            if (guid_token == null || guid_token.Type == JTokenType.Null)
            {
                return(result);
            }
            Guid guid = Guid.Empty;

            if (Guid.TryParse(guid_token.Value <string>(), out guid))
            {
                result.guid = guid;
            }

            return(result);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Create an asset dependency of type <paramref name="type"/> and pointing to <paramref name="item"/>
        /// </summary>
        /// <param name="item">The item the dependency is pointing to</param>
        /// <param name="type">The type of the dependency between the items</param>
        public AssetLink(AssetItem item, ContentLinkType type)
        {
            if (item == null) throw new ArgumentNullException("item");

            Item = item;
            this.type = type;
            reference = item.ToReference();
        }
Exemplo n.º 4
0
        // This constructor exists for better factorization of code in AssetDependencies. 
        // It should not be turned into public as AssetItem is not valid.
        internal AssetLink(IContentReference reference, ContentLinkType type)
        {
            if (reference == null) throw new ArgumentNullException("reference");

            Item = null;
            this.type = type;
            this.reference = reference;
        }
Exemplo n.º 5
0
 /// <summary>
 /// Creates a proxy object with <see cref="AttachedReference" /> designing it as a proxy with a given id and location (that can be used with <see cref="Assets.AssetManager" />). This allows to construct and save object references without actually loading them.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="contentReference">The content reference.</param>
 /// <returns>T.</returns>
 /// <exception cref="System.ArgumentNullException">contentReference</exception>
 public static T CreateSerializableVersion <T>(IContentReference contentReference) where T : class, new()
 {
     if (contentReference == null)
     {
         throw new ArgumentNullException("contentReference");
     }
     return(CreateSerializableVersion <T>(contentReference.Id, contentReference.Location));
 }
Exemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AssetLogMessage" /> class.
 /// </summary>
 /// <param name="package">The package.</param>
 /// <param name="assetReference">The asset reference.</param>
 /// <param name="type">The type.</param>
 /// <param name="messageCode">The message code.</param>
 /// <exception cref="System.ArgumentNullException">asset</exception>
 public AssetLogMessage(Package package, IContentReference assetReference, LogMessageType type, AssetMessageCode messageCode)
 {
     this.package = package;
     AssetReference = assetReference;
     Type = type;
     MessageCode = messageCode;
     Related = new List<IContentReference>();
     Text = AssetMessageStrings.ResourceManager.GetString(messageCode.ToString()) ?? messageCode.ToString();
 }
Exemplo n.º 7
0
 public static void Warning(this ILogger logger, Package package, IContentReference assetReference, AssetMessageCode code, IEnumerable<IContentReference> relatedGuids, params object[] arguments)
 {
     var logMessage = new AssetLogMessage(package, assetReference, LogMessageType.Warning, code, arguments);
     if (relatedGuids != null)
     {
         logMessage.Related.AddRange(relatedGuids);
     }
     logger.Log(logMessage);
 }
Exemplo n.º 8
0
 public static void Error(this ILogger logger, Package package, IContentReference assetReference, AssetMessageCode code, IEnumerable<IContentReference> relatedGuids, Exception exception = null)
 {
     var logMessage = new AssetLogMessage(package, assetReference, LogMessageType.Error, code) { Exception = exception };
     if (relatedGuids != null)
     {
         logMessage.Related.AddRange(relatedGuids);
     }
     logger.Log(logMessage);
 }
Exemplo n.º 9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AssetLogMessage" /> class.
 /// </summary>
 /// <param name="package">The package.</param>
 /// <param name="assetReference">The asset reference.</param>
 /// <param name="type">The type.</param>
 /// <param name="messageCode">The message code.</param>
 /// <exception cref="System.ArgumentNullException">asset</exception>
 public AssetLogMessage(Package package, IContentReference assetReference, LogMessageType type, AssetMessageCode messageCode)
 {
     this.package   = package;
     AssetReference = assetReference;
     Type           = type;
     MessageCode    = messageCode;
     Related        = new List <IContentReference>();
     Text           = AssetMessageStrings.ResourceManager.GetString(messageCode.ToString()) ?? messageCode.ToString();
 }
Exemplo n.º 10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AssetLogMessage" /> class.
 /// </summary>
 /// <param name="package">The package.</param>
 /// <param name="assetReference">The asset reference.</param>
 /// <param name="type">The type.</param>
 /// <param name="messageCode">The message code.</param>
 /// <param name="arguments">The arguments.</param>
 /// <exception cref="System.ArgumentNullException">asset</exception>
 public AssetLogMessage(Package package, IContentReference assetReference, LogMessageType type, AssetMessageCode messageCode, params object[] arguments)
 {
     this.package = package;
     AssetReference = assetReference;
     Type = type;
     MessageCode = messageCode;
     Related = new List<IContentReference>();
     var message = AssetMessageStrings.ResourceManager.GetString(messageCode.ToString()) ?? messageCode.ToString();
     Text = string.Format(message, arguments);
 }
Exemplo n.º 11
0
        public static void Warning(this ILogger logger, Package package, IContentReference assetReference, AssetMessageCode code, IEnumerable <IContentReference> relatedGuids, params object[] arguments)
        {
            var logMessage = new AssetLogMessage(package, assetReference, LogMessageType.Warning, code, arguments);

            if (relatedGuids != null)
            {
                logMessage.Related.AddRange(relatedGuids);
            }
            logger.Log(logMessage);
        }
Exemplo n.º 12
0
        public virtual T Get(string name)
        {
            IContentReference result = null;

            if (Entries.TryGetValue(name, out result))
            {
                return(Converter(result.GetGeneric()));
            }

            return(default(T));
        }
Exemplo n.º 13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AssetLogMessage" /> class.
        /// </summary>
        /// <param name="package">The package.</param>
        /// <param name="assetReference">The asset reference.</param>
        /// <param name="type">The type.</param>
        /// <param name="messageCode">The message code.</param>
        /// <param name="arguments">The arguments.</param>
        /// <exception cref="System.ArgumentNullException">asset</exception>
        public AssetLogMessage(Package package, IContentReference assetReference, LogMessageType type, AssetMessageCode messageCode, params object[] arguments)
        {
            this.package   = package;
            AssetReference = assetReference;
            Type           = type;
            MessageCode    = messageCode;
            Related        = new List <IContentReference>();
            var message = AssetMessageStrings.ResourceManager.GetString(messageCode.ToString()) ?? messageCode.ToString();

            Text = string.Format(message, arguments);
        }
Exemplo n.º 14
0
        // This constructor exists for better factorization of code in AssetDependencies.
        // It should not be turned into public as AssetItem is not valid.
        internal AssetLink(IContentReference reference, ContentLinkType type)
        {
            if (reference == null)
            {
                throw new ArgumentNullException("reference");
            }

            Item           = null;
            this.type      = type;
            this.reference = reference;
        }
Exemplo n.º 15
0
        /// <summary>
        /// Create an asset dependency of type <paramref name="type"/> and pointing to <paramref name="item"/>
        /// </summary>
        /// <param name="item">The item the dependency is pointing to</param>
        /// <param name="type">The type of the dependency between the items</param>
        public AssetLink(AssetItem item, ContentLinkType type)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            Item      = item;
            this.type = type;
            reference = item.ToReference();
        }
 // Token: 0x06000FD1 RID: 4049 RVA: 0x00069374 File Offset: 0x00067774
 public void OnDrop(PointerEventData eventData)
 {
     if (!(Sleek2DragManager.item is IContentReference))
     {
         return;
     }
     if (typeof(T).IsAssignableFrom(Sleek2DragManager.item.GetType().GetGenericArguments()[0]))
     {
         IContentReference contentReference = (IContentReference)Sleek2DragManager.item;
         this.triggerContentReferenceDocked(new ContentReference <T>(contentReference));
     }
 }
Exemplo n.º 17
0
 /// <summary>
 /// Adds a missing reference.
 /// </summary>
 /// <param name="contentReference">The content reference.</param>
 /// <exception cref="System.ArgumentNullException">contentReference</exception>
 public void AddMissingReference(IContentReference contentReference)
 {
     if (contentReference == null)
     {
         throw new ArgumentNullException("contentReference");
     }
     if (missingReferences == null)
     {
         missingReferences = new List <IContentReference>();
     }
     missingReferences.Add(contentReference);
 }
Exemplo n.º 18
0
 public static bool isSameAs(this IContentReference source, IContentReference target)
 {
     if (source == null && target == null)
     {
         return(true);
     }
     //one of them is not null, so what to use Equals class methods
     if (source != null)
     {
         return(source.Equals(target));
     }
     return(target.Equals(source));
 }
Exemplo n.º 19
0
        public static void Error(this ILogger logger, Package package, IContentReference assetReference, AssetMessageCode code, IEnumerable <IContentReference> relatedGuids, Exception exception = null)
        {
            var logMessage = new AssetLogMessage(package, assetReference, LogMessageType.Error, code)
            {
                Exception = exception
            };

            if (relatedGuids != null)
            {
                logMessage.Related.AddRange(relatedGuids);
            }
            logger.Log(logMessage);
        }
Exemplo n.º 20
0
 public static void Error(this ILogger logger, Package package, IContentReference assetReference, AssetMessageCode code, params object[] arguments)
 {
     Error(logger, package, assetReference, code, (IEnumerable <IContentReference>)null, arguments);
 }
Exemplo n.º 21
0
 public static void Error(this ILogger logger, Package package, IContentReference assetReference, AssetMessageCode code, IEnumerable <IContentReference> relatedGuids, params object[] arguments)
 {
     Error(logger, package, assetReference, code, relatedGuids, (Exception)null, arguments);
 }
Exemplo n.º 22
0
 public static void Error(this ILogger logger, Package package, IContentReference assetReference, AssetMessageCode code, IContentReference[] relatedGuids, Exception exception = null)
 {
     Error(logger, package, assetReference, code, (IEnumerable<IContentReference>)relatedGuids, exception);
 }
Exemplo n.º 23
0
 /// <summary>
 /// Finds an asset from all the packages by its asset reference.
 /// It will first try by id, then location.
 /// </summary>
 /// <param name="package">The package.</param>
 /// <param name="contentReference">The reference to the asset.</param>
 /// <returns>An <see cref="AssetItem" /> or <c>null</c> if not found.</returns>
 public static AssetItem FindAsset(this Package package, IContentReference contentReference)
 {
     return(package.FindAsset(contentReference.Id) ?? package.FindAsset(contentReference.Location));
 }
Exemplo n.º 24
0
 /// <summary>
 /// Adds a broken link out.
 /// </summary>
 /// <param name="reference">the reference to the missing element</param>
 /// <param name="contentLinkType">The type of link</param>
 /// <exception cref="ArgumentException">A broken link to this element already exists</exception>
 public void AddBrokenLinkOut(IContentReference reference, ContentLinkType contentLinkType)
 {
     AddLink(ref missingChildren, new AssetLink(reference, contentLinkType), false);
 }
Exemplo n.º 25
0
 public static bool isSameAs <T>(this IContentReference source, T target) where T : IContent, new()
 {
     return(isSameAs(source, (IContentReference) new ContentReference <T>(target)));
 }
Exemplo n.º 26
0
 public static bool isReferedBy <T>(this T source, IContentReference target) where T : IContent, new()
 {
     return(target.isSameAs(source));
 }
Exemplo n.º 27
0
 public static void Error(this ILogger logger, Package package, IContentReference assetReference, AssetMessageCode code, IEnumerable<IContentReference> relatedGuids, params object[] arguments)
 {
     Error(logger, package, assetReference, code, relatedGuids, (Exception)null, arguments);
 }
Exemplo n.º 28
0
 /// <summary>
 /// Adds a broken link out.
 /// </summary>
 /// <param name="reference">the reference to the missing element</param>
 /// <param name="contentLinkType">The type of link</param>
 /// <exception cref="ArgumentException">A broken link to this element already exists</exception>
 public void AddBrokenLinkOut(IContentReference reference, ContentLinkType contentLinkType)
 {
     AddLink(ref missingChildren, new AssetLink(reference, contentLinkType), false);
 }
Exemplo n.º 29
0
 private static bool IsNewReference(Tuple <Guid, UFile> newReference, IContentReference previousReference)
 {
     return(newReference.Item1 != previousReference.Id ||
            newReference.Item2 != previousReference.Location);
 }
Exemplo n.º 30
0
 public static void Error(this ILogger logger, Package package, IContentReference assetReference, AssetMessageCode code, Exception exception, params object[] arguments)
 {
     Error(logger, package, assetReference, code, null, exception, arguments);
 }
Exemplo n.º 31
0
 public static void Warning(this ILogger logger, Package package, IContentReference assetReference, AssetMessageCode code, params object[] arguments)
 {
     Warning(logger, package, assetReference, code, null, arguments);
 }
Exemplo n.º 32
0
 /// <summary>
 /// Finds an asset from all the packages by its asset reference.
 /// It will first try by id, then location.
 /// </summary>
 /// <param name="package">The package.</param>
 /// <param name="contentReference">The reference to the asset.</param>
 /// <returns>An <see cref="AssetItem" /> or <c>null</c> if not found.</returns>
 public static AssetItem FindAsset(this Package package, IContentReference contentReference)
 {
     return package.FindAsset(contentReference.Id) ?? package.FindAsset(contentReference.Location);
 }
Exemplo n.º 33
0
 public static void Error(this ILogger logger, Package package, IContentReference assetReference, AssetMessageCode code, IContentReference[] relatedGuids, Exception exception = null)
 {
     Error(logger, package, assetReference, code, (IEnumerable <IContentReference>)relatedGuids, exception);
 }
Exemplo n.º 34
0
 public static void Error(this ILogger logger, Package package, IContentReference assetReference, AssetMessageCode code, Exception exception, params object[] arguments)
 {
     Error(logger, package, assetReference, code, null, exception, arguments);
 }
Exemplo n.º 35
0
 public static void Warning(this ILogger logger, Package package, IContentReference assetReference, AssetMessageCode code, IContentReference[] relatedGuids)
 {
     Warning(logger, package, assetReference, code, (IEnumerable<IContentReference>)null);
 }
Exemplo n.º 36
0
 public static void Warning(this ILogger logger, Package package, IContentReference assetReference, AssetMessageCode code, params object[] arguments)
 {
     Warning(logger, package, assetReference, code, null, arguments);
 }
Exemplo n.º 37
0
 public static void Warning(this ILogger logger, Package package, IContentReference assetReference, AssetMessageCode code, IContentReference[] relatedGuids)
 {
     Warning(logger, package, assetReference, code, (IEnumerable <IContentReference>)null);
 }
Exemplo n.º 38
0
 public void Add(IContentReference reference)
 {
     Pending.Add(reference);
 }
Exemplo n.º 39
0
 // Token: 0x06001998 RID: 6552 RVA: 0x000907B5 File Offset: 0x0008EBB5
 public ContentReference(IContentReference contentReference)
 {
     this.name = contentReference.name;
     this.path = contentReference.path;
 }
Exemplo n.º 40
0
 public static void Error(this ILogger logger, Package package, IContentReference assetReference, AssetMessageCode code, params object[] arguments)
 {
     Error(logger, package, assetReference, code, (IEnumerable<IContentReference>)null, arguments);
 }