public Enumerator(IListClassProperty <TContainer, TValue> property, TContainer container) { m_Property = property; m_Container = container; m_Index = 0; Current = default(TValue); }
public static void GenerateAOTFunctions <TProperty, TContainer, TValue>() where TProperty : IProperty <TContainer, TValue> { TProperty property = default(TProperty); TContainer container = default(TContainer); TValue value = default(TValue); ChangeTracker changeTracker = default(ChangeTracker); PropertyVisitor propertyVisitor = new PropertyVisitor(); propertyVisitor.TryVisitContainerWithAdapters(property, ref container, ref value, ref changeTracker); propertyVisitor.TryVisitValueWithAdapters(property, ref container, ref value, ref changeTracker); PropertyVisitorAdapterExtensions.TryVisitContainer(null, null, property, ref container, ref value, ref changeTracker); PropertyVisitorAdapterExtensions.TryVisitValue(null, null, property, ref container, ref value, ref changeTracker); Actions.GetCollectionCountGetter <TContainer> getCollectionCountGetter = new Actions.GetCollectionCountGetter <TContainer>(); Actions.GetCountFromActualTypeCallback getCountFromActualTypeCallback = new Actions.GetCountFromActualTypeCallback(); getCountFromActualTypeCallback.Invoke <TContainer>(); getCountFromActualTypeCallback.Invoke <TValue>(); Actions.GetCountAtPathGetter <TContainer> getCountAtPathGetter = new Actions.GetCountAtPathGetter <TContainer>(); Actions.VisitAtPathCallback visitAtPathCallback = default; visitAtPathCallback.Invoke <TContainer>(); visitAtPathCallback.Invoke <TValue>(); Actions.SetCountCallback setCountCallback = default; setCountCallback.Invoke <TContainer>(); setCountCallback.Invoke <TValue>(); Actions.TryGetCount(ref container, new PropertyPath(), 0, ref changeTracker, out var count); Actions.TryGetCountImpl(ref container, new PropertyPath(), 0, ref changeTracker, out var otherCount); Actions.GetCount(ref container, new PropertyPath(), 0, ref changeTracker); }
/// <summary> /// Creates a new resource with the full path name provided. /// </summary> public static TContainer Create <TContainer>() where TContainer : class, IContainer, new() { var temporaryResource = new TContainer(); return(Create <TContainer>(ResourceManagement.CommandConfiguration.TempPath, temporaryResource.FullName)); }
public override IEnumerable <ChildInfo> GetPossibleChildrenFor(TContainer container) { var description = AttributeUtils.GetAttributes <DescriptionAttribute, TProperty>().FirstOrDefault(); return(new[] { new ChildInfo( name: _name, description: description?.Description, create: () => new SetValueCommand <TProperty>(_getPointer(container), new TProperty())) }); }
public static void GenerateAOTCollectionFunctions <TProperty, TContainer, TValue>() where TProperty : ICollectionProperty <TContainer, TValue> { TProperty property = default(TProperty); TContainer container = default(TContainer); TValue value = default(TValue); ChangeTracker changeTracker = default(ChangeTracker); var getter = new VisitCollectionElementCallback <TContainer>(); PropertyVisitor propertyVisitor = new PropertyVisitor(); propertyVisitor.TryVisitContainerWithAdapters(property, ref container, ref value, ref changeTracker); propertyVisitor.TryVisitCollectionWithAdapters(property, ref container, ref value, ref changeTracker); propertyVisitor.TryVisitValueWithAdapters(property, ref container, ref value, ref changeTracker); PropertyVisitorAdapterExtensions.TryVisitCollection(null, null, property, ref container, ref value, ref changeTracker); PropertyVisitorAdapterExtensions.TryVisitContainer(null, null, property, ref container, ref value, ref changeTracker); PropertyVisitorAdapterExtensions.TryVisitValue(null, null, property, ref container, ref value, ref changeTracker); var arrayProperty = new ArrayProperty <TContainer, TValue>(); arrayProperty.GetPropertyAtIndex(ref container, 0, ref changeTracker, ref getter); var arrayCollectionElementProperty = new ArrayProperty <TContainer, TValue> .CollectionElementProperty(); arrayCollectionElementProperty.GetValue(ref container); arrayCollectionElementProperty.SetValue(ref container, value); propertyVisitor.VisitProperty <ArrayProperty <TContainer, TValue> .CollectionElementProperty, TContainer, TValue>(arrayCollectionElementProperty, ref container, ref changeTracker); var listProperty = new ListProperty <TContainer, TValue>(); listProperty.GetPropertyAtIndex(ref container, 0, ref changeTracker, ref getter); var listCollectionElementProperty = new ListProperty <TContainer, TValue> .CollectionElementProperty(); listCollectionElementProperty.GetValue(ref container); listCollectionElementProperty.SetValue(ref container, value); propertyVisitor.VisitProperty <ListProperty <TContainer, TValue> .CollectionElementProperty, TContainer, TValue>(listCollectionElementProperty, ref container, ref changeTracker); Actions.GetCollectionCountGetter <TContainer> getCollectionCountGetter = new Actions.GetCollectionCountGetter <TContainer>(); Actions.GetCountFromActualTypeCallback getCountFromActualTypeCallback = new Actions.GetCountFromActualTypeCallback(); getCountFromActualTypeCallback.Invoke <TContainer>(); getCountFromActualTypeCallback.Invoke <TValue>(); Actions.GetCountAtPathGetter <TContainer> getCountAtPathGetter = new Actions.GetCountAtPathGetter <TContainer>(); Actions.VisitAtPathCallback visitAtPathCallback = default; visitAtPathCallback.Invoke <TContainer>(); visitAtPathCallback.Invoke <TValue>(); Actions.SetCountCallback setCountCallback = default; setCountCallback.Invoke <TContainer>(); setCountCallback.Invoke <TValue>(); Actions.TryGetCount(ref container, new PropertyPath(), 0, ref changeTracker, out var count); Actions.TryGetCountImpl(ref container, new PropertyPath(), 0, ref changeTracker, out var otherCount); Actions.GetCount(ref container, new PropertyPath(), 0, ref changeTracker); }
public sealed override void Write(ref TContainer container, string memberName, Utf8JsonWriter writer, JsonSerializerOptions options) { if (IsReadable) { Get(ref container, out var value); if (!options.IgnoreNullValues || !(value is null)) { writer.WritePropertyName(memberName); JsonSerializer.Serialize(writer, value, options); } } }
public sealed override void Read(ref TContainer container, ref Utf8JsonReader reader, JsonSerializerOptions options) { if (IsWritable) { var value = JsonSerializer.Deserialize <TMember>(ref reader, options); if (!options.IgnoreNullValues || !(value is null)) { Set(ref container, in value); } } else { reader.Skip(); } }
public static unsafe void GenerateAOTFunctions <TProperty, TContainer, TValue>() where TProperty : IProperty <TContainer, TValue> { TProperty property = default(TProperty); TContainer container = default(TContainer); ChangeTracker changeTracker = default(ChangeTracker); UnsafeAppendBuffer.Reader *reader = null; var propertyReader = new PropertiesBinaryReader(reader, null); propertyReader.VisitProperty <TProperty, TContainer, TValue>(property, ref container, ref changeTracker); propertyReader.IsExcluded <TProperty, TContainer, TValue>(property, ref container); Properties.AOTFunctionGenerator.GenerateAOTContainerFunctions <DictionaryContainer <object, object> >(); Properties.AOTFunctionGenerator.GenerateAOTContainerFunctions <PolymorphicTypeName>(); Properties.AOTFunctionGenerator.GenerateAOTContainerFunctions <PolymorphicTypeContainer <TContainer> >(); Properties.AOTFunctionGenerator.GenerateAOTContainerFunctions <PolymorphicTypeContainer <TValue> >(); }
// Unused variables #pragma warning disable 0219 public static void GenerateAOTContainerFunctions <TContainer>() { TContainer container = default(TContainer); ChangeTracker changeTracker = default(ChangeTracker); Actions.GetCollectionCountGetter <TContainer> getCollectionCountGetter = new Actions.GetCollectionCountGetter <TContainer>(); Actions.GetCountFromActualTypeCallback getCountFromActualTypeCallback = new Actions.GetCountFromActualTypeCallback(); getCountFromActualTypeCallback.Invoke <TContainer>(); Actions.GetCountAtPathGetter <TContainer> getCountAtPathGetter = new Actions.GetCountAtPathGetter <TContainer>(); Actions.VisitAtPathCallback visitAtPathCallback = default; visitAtPathCallback.Invoke <TContainer>(); Actions.SetCountCallback setCountCallback = default; setCountCallback.Invoke <TContainer>(); Actions.TryGetCount(ref container, new PropertyPath(), 0, ref changeTracker, out var count); Actions.TryGetCountImpl(ref container, new PropertyPath(), 0, ref changeTracker, out var otherCount); Actions.GetCount(ref container, new PropertyPath(), 0, ref changeTracker); }
public override IEnumerable <EntryInfo> GetEntriesIn(TContainer container) { var pointer = _getPointer(container); if (pointer.Value != null) { var description = AttributeUtils.GetAttributes <DescriptionAttribute, TProperty>().FirstOrDefault(); yield return(new EntryInfo( name: _name, description: description?.Description, target: pointer.Value, getEditorControl: executor => CreateEditor(container, pointer.Value, executor), toXmlString: () => pointer.Value.ToXmlString(), fromXmlString: xmlString => { var newValue = XmlStorage.FromXmlString <TProperty>(xmlString); return newValue.Equals(pointer.Value) ? null : new SetValueCommand <TProperty>(pointer, newValue); }, removeCommand: new SetValueCommand <TProperty>(pointer, null))); } }
public EntryInfo TryGetEntry(TContainer container, IList <TList> list, TList candidate) { if (!(candidate is TElement element)) { return(null); } var description = AttributeUtils.GetAttributes <DescriptionAttribute, TElement>().FirstOrDefault(); return(new EntryInfo( name: _name, description: description?.Description, target: element, getEditorControl: executor => CreateEditor(container, element, executor), toXmlString: () => element.ToXmlString(), fromXmlString: xmlString => { var newValue = XmlStorage.FromXmlString <TElement>(xmlString); return newValue.Equals(element) ? null : new ReplaceInList <TList>(list, element, newValue); }, removeCommand: new RemoveFromCollection <TList>(list, element))); }
internal DeserializationContext(TContainer container, string assetPath) { Asset = container; AssetPath = assetPath; }
public MessageHandler(TContainer container, TAttribute handlerAttribute, Action <object, TClient, Message> action) { Container = container; Attribute = handlerAttribute; Action = action; }
public abstract IEnumerable <ChildInfo> GetPossibleChildrenFor(TContainer container);
public abstract IEnumerable <EntryInfo> GetEntriesIn(TContainer container);
protected virtual TEditor CreateEditor(TContainer container, TProperty value, Undo.ICommandExecutor executor) => new TEditor { Target = value, CommandExecutor = executor };
public void VisitCollectionProperty <TProperty, TValue>(TProperty property, ref TContainer container, ref ChangeTracker changeTracker) where TProperty : ICollectionProperty <TContainer, TValue> { property.SetCount(ref container, m_Count); }
public void VisitProperty <TProperty, TValue>(TProperty property, ref TContainer container, ref ChangeTracker changeTracker) where TProperty : IProperty <TContainer, TValue> { throw new NotImplementedException($"Failed to {nameof(SetCount)}. Property is not a collection"); }
protected override TEditor CreateEditor(TContainer container, TProperty value, Undo.ICommandExecutor executor) => new TEditor { Target = value, ContainerRef = container, CommandExecutor = executor };
public void FindProperty <TCallback>(ref TContainer container, ref ChangeTracker changeTracker, ref TCallback callback) where TCallback : IPropertyGetter <TContainer> => callback.VisitProperty <TProperty, TValue>(Property, ref container, ref changeTracker);
public void FindProperty <TCallback>(ref TContainer container, ref ChangeTracker changeTracker, ref TCallback callback) where TCallback : IPropertyQuery <TContainer> => callback.VisitCollectionProperty <TProperty, TValue>(Property, ref container, ref changeTracker);
public void Accept <TVisitor>(ref TContainer container, TVisitor visitor, ref ChangeTracker changeTracker) where TVisitor : IPropertyVisitor => visitor.VisitCollectionProperty <TProperty, TContainer, TValue>(Property, ref container, ref changeTracker);