public static void Main (string[] args) { Debug.Active = true; Debug.DevelopmentInfo = true; ConsoleDebug.Connect(); // Test case of complex mapping resolving string tm = "(CLASS) propname [column name:: prop1>>PROP1; prop2<>PROP2; prop3<>PROP3]>>resultprop"; SMappedItem mi = new SMappedItem (tm); Console.WriteLine (mi); IVirtualObject nobj = new UniqueVirtualObject ("BLAHBLAH2"); nobj.AddProperty ("FullName", typeof (string)); IVirtualObject obj = new UniqueVirtualObject ("BLAHBLAH"); obj.InheritStrict (nobj); obj.AddProperty ("Name", typeof (string)); obj.AddProperty ("Int", typeof (int)); obj["FullName"].Value = "FULLNAME"; obj["Name"].OnChange += OnPropChange; obj["Name"].Value = "some string"; obj["Int"].Value = 123; Console.WriteLine ("VirtualObject(" + obj.ObjectType.Name + ") FullName='" + obj["FullName"].Value + "' Name='" + obj["Name"].Value + "' Int=" + obj["Int"].Value); VirtualObject obj2 = new UniqueVirtualObject ("BLAHBLAH2", obj); Console.WriteLine ("VirtualObject(" + obj2.ObjectType.Name + ") FullName='" + obj2["FullName"].Value + "' Name='" + obj2["Name"].Value + "' Int=" + obj2["Int"].Value); obj = null; Application.Init (); MainWindow win = new MainWindow (); win.Show (); Application.Run (); }
/// <summary> /// Creates Mapped property /// </summary> /// <param name="aMasterItem"> /// Master item <see cref="MappedProperty"/> /// </param> /// <param name="aItem"> /// Item <see cref="SMappedItem"/> /// </param> public MappedProperty(MappedProperty aMasterItem, SMappedItem aItem) { if (aMasterItem == null) { throw new ExceptionMasterItemIsNull(); } masterItem = aMasterItem; isSubItem = true; adaptor = new WeakReference(masterItem.Adaptor); /* if (Adaptor.IsBoundaryAdaptor == true) * throw new Exception ("You can't set Boundary Mapping to non-Boundary adaptor >> Name=" + aItem.Name + " Target=" + aItem.MappedItem);*/ Name = aItem.Name; BoundingClassName = aItem.ClassName; mappingTarget = aItem.MappedItem; originalRWFlags = aItem.RWFlags; RWFlags = aItem.RWFlags; // aMasterItem.Submappings.AddMapping(this); }
public static void Main(string[] args) { Debug.Active = true; Debug.DevelopmentInfo = true; ConsoleDebug.Connect(); // Test case of complex mapping resolving string tm = "(CLASS) propname [column name:: prop1>>PROP1; prop2<>PROP2; prop3<>PROP3]>>resultprop"; SMappedItem mi = new SMappedItem(tm); Console.WriteLine(mi); IVirtualObject nobj = new UniqueVirtualObject("BLAHBLAH2"); nobj.AddProperty("FullName", typeof(string)); IVirtualObject obj = new UniqueVirtualObject("BLAHBLAH"); obj.InheritStrict(nobj); obj.AddProperty("Name", typeof(string)); obj.AddProperty("Int", typeof(int)); obj["FullName"].Value = "FULLNAME"; obj["Name"].OnChange += OnPropChange; obj["Name"].Value = "some string"; obj["Int"].Value = 123; Console.WriteLine("VirtualObject(" + obj.ObjectType.Name + ") FullName='" + obj["FullName"].Value + "' Name='" + obj["Name"].Value + "' Int=" + obj["Int"].Value); VirtualObject obj2 = new UniqueVirtualObject("BLAHBLAH2", obj); Console.WriteLine("VirtualObject(" + obj2.ObjectType.Name + ") FullName='" + obj2["FullName"].Value + "' Name='" + obj2["Name"].Value + "' Int=" + obj2["Int"].Value); obj = null; Application.Init(); MainWindow win = new MainWindow(); win.Show(); Application.Run(); }
/// <summary> /// Adds new mapping /// </summary> /// <param name="aName"> /// Mapping name <see cref="System.String"/> /// </param> /// <param name="aType"> /// Type of mapping <see cref="System.Type"/> /// </param> /// <param name="aRW"> /// Read-write settings for mapped property <see cref="EReadWrite"/> /// </param> /// <param name="aClassName"> /// Defines class name <see cref="System.String"/> /// </param> /// <param name="aIsColumn"> /// Defines if mapping is coumn mapping or not <see cref="System.Boolean"/> /// </param> /// <param name="aColumnName"> /// Name of column <see cref="System.String"/> /// </param> /// <param name="aMapping"> /// Mapping string <see cref="System.String"/> /// </param> /// <param name="aSubItems"> /// List of subitems <see cref="SMappedItem"/> /// </param> /// <returns> /// Returns true if successful <see cref="System.Boolean"/> /// </returns> public bool AddMapping (string aName, System.Type aType, EReadWrite aRW, string aClassName, bool aIsColumn, string aColumnName, string aMapping, SMappedItem[] aSubItems) { cachedMappings = false; MappedProperty mp = Values[aName]; if (mp != null) { // There is one case when duplicate is allowed, if there is only one as global and // only one as default bool found = false; foreach (MappedProperty mpr in Values) if ((mpr.Name == aName) && (mpr.IsColumnMapping == aIsColumn)) found = true; if (found == false) mp = null; } if (mp != null) { if (mp.BoundingClassName != aClassName) mp.BoundingClassName = aClassName; if (mp.IsColumnMapping != aIsColumn) mp.IsColumnMapping = aIsColumn; if (mp.ColumnName != aColumnName) mp.ColumnName = aColumnName; if (mp.MappingTarget != aMapping) mp.MappingTarget = aMapping; mp = null; throw new ExceptionAddWrongMapping(); } if (aName == "") throw new ExceptionAddEmptyMapping(); isValidated = false; if (IsBoundaryAdaptor == true) if (aClassName != "") mappingList.Add (new MappedProperty (this, aClassName, aName, aRW, aMapping)); else mappingList.Add (new MappedProperty (this, aName, aRW, aMapping)); else if ((aIsColumn == true) && (aColumnName != "")) if (aMapping == "") mappingList.Add (new MappedProperty (this, true, aName, aColumnName, aRW, aSubItems)); else mappingList.Add (new MappedProperty (this, true, aName, aColumnName, aRW, aMapping, aSubItems)); else if (aMapping == "") mappingList.Add (new MappedProperty (this, aName)); else mappingList.Add (new MappedProperty (this, aName, aRW, aMapping)); if (HasDefaultMapping == false) hasDefaultMapping = (GetDefaultProperty() != null); return (true); }
/// <summary> /// Creates Mapped property /// </summary> /// <param name="aAdaptor"> /// Adaptor mapped property is connected to <see cref="IAdaptor"/> /// </param> /// <param name="aIsColumn"> /// Defines if this is column or not <see cref="System.Boolean"/> /// </param> /// <param name="aName"> /// Name of mapped property <see cref="System.String"/> /// </param> /// <param name="aColumnName"> /// Name of column <see cref="System.String"/> /// </param> /// <param name="aRWFlags"> /// Read write flags <see cref="EReadWrite"/> /// </param> /// <param name="aTarget"> /// Target mapping <see cref="System.String"/> /// </param> /// <param name="aSubItems"> /// Sub items <see cref="SMappedItem"/> /// </param> public MappedProperty (IAdaptor aAdaptor, bool aIsColumn, string aName, string aColumnName, EReadWrite aRWFlags, string aTarget, SMappedItem[] aSubItems) { // Targeted Column Mapped property if (aAdaptor == null) throw new ExceptionMappedPropertyWithNullAdaptor(); adaptor = new WeakReference (aAdaptor); if (Adaptor.IsBoundaryAdaptor == true) throw new ExceptionNonBoundaryMappingSetToBoundary (aName, aTarget, aColumnName); Name = aName; submappings = new ChildMappedProperties(); mappingTarget = aTarget; IsColumnMapping = aIsColumn; if (IsColumnMapping == true) submappings = new ChildMappedProperties(); ColumnName = aColumnName; originalRWFlags = aRWFlags; RWFlags = aRWFlags; if (aSubItems != null) foreach (SMappedItem item in aSubItems) Submappings.AddMapping (new MappedProperty (this, item)); if (aTarget == "") throw new ExceptionMappingRequiresDefinedTarget (aName); Resolve(); }
/// <summary> /// Creates Mapped property /// </summary> /// <param name="aAdaptor"> /// Adaptor mapped property is connected to <see cref="IAdaptor"/> /// </param> /// <param name="aIsColumn"> /// Defines if this is column or not <see cref="System.Boolean"/> /// </param> /// <param name="aName"> /// Name of mapped property <see cref="System.String"/> /// </param> /// <param name="aColumnName"> /// Name of column <see cref="System.String"/> /// </param> /// <param name="aRWFlags"> /// Read write flags <see cref="EReadWrite"/> /// </param> /// <param name="aSubItems"> /// Sub items <see cref="SMappedItem"/> /// </param> public MappedProperty (IAdaptor aAdaptor, bool aIsColumn, string aName, string aColumnName, EReadWrite aRWFlags, SMappedItem[] aSubItems) { // Column Mapped property if (aAdaptor == null) throw new ExceptionMappedPropertyWithNullAdaptor(); submappings = new ChildMappedProperties(); adaptor = new WeakReference (aAdaptor); if (Adaptor.IsBoundaryAdaptor == true) throw new ExceptionNonBoundaryMappingSetToBoundary (aName, true, aColumnName); Name = aName; IsColumnMapping = aIsColumn; originalRWFlags = aRWFlags; RWFlags = aRWFlags; if (IsColumnMapping == true) submappings = new ChildMappedProperties(); if (aSubItems != null) { Submappings.Size = aSubItems.Length; foreach (SMappedItem item in aSubItems) Submappings.AddMapping (new MappedProperty (this, item)); } ColumnName = aColumnName; Resolve(); }
/// <summary> /// Creates Mapped property /// </summary> /// <param name="aMasterItem"> /// Master item <see cref="MappedProperty"/> /// </param> /// <param name="aItem"> /// Item <see cref="SMappedItem"/> /// </param> public MappedProperty (MappedProperty aMasterItem, SMappedItem aItem) { if (aMasterItem == null) throw new ExceptionMasterItemIsNull(); masterItem = aMasterItem; isSubItem = true; adaptor = new WeakReference (masterItem.Adaptor); /* if (Adaptor.IsBoundaryAdaptor == true) throw new Exception ("You can't set Boundary Mapping to non-Boundary adaptor >> Name=" + aItem.Name + " Target=" + aItem.MappedItem);*/ Name = aItem.Name; BoundingClassName = aItem.ClassName; mappingTarget = aItem.MappedItem; originalRWFlags = aItem.RWFlags; RWFlags = aItem.RWFlags; // aMasterItem.Submappings.AddMapping(this); }