Exemplo n.º 1
0
        public PropertiesChangedAction GetPropertyChangeAction(string prop, object newval)
        {
            if (WrappedObject == null)
            {
                return(null);
            }
            if (WrappedObject is PARAM.Row row)
            {
                var pp = row[prop];
                if (pp != null)
                {
                    var pprop = pp.GetType().GetProperty("Value");
                    return(new PropertiesChangedAction(pprop, pp, newval));
                }
            }
            if (WrappedObject is MergedParamRow mrow)
            {
                var pp = mrow[prop];
                if (pp != null)
                {
                    var pprop = pp.GetType().GetProperty("Value");
                    return(new PropertiesChangedAction(pprop, pp, newval));
                }
            }
            var p = WrappedObject.GetType().GetProperty(prop);

            if (p != null)
            {
                return(new PropertiesChangedAction(p, WrappedObject, newval));
            }
            return(null);
        }
Exemplo n.º 2
0
 public void DefaultAction()
 {
     if (Data.Type == EventTypes.Click)
     {
         WrappedObject     tempTarget    = Target;
         HTMLAnchorElement anchorElement = tempTarget as HTMLAnchorElement;
         tempTarget = tempTarget.Parent;
         while (anchorElement == null && tempTarget != null)
         {
             anchorElement = tempTarget as HTMLAnchorElement;
             tempTarget    = tempTarget.Parent;
         }
         if (anchorElement != null)
         {
             string newHref = anchorElement.Href;
             if (newHref != null)
             {
                 ContentWindow window = mdr.Runtime.Instance.GlobalContext as ContentWindow;
                 Debug.Assert(window != null, "In handling the default action for Click Content Window cannot be retrived!");
                 if (window != null)
                 {
                     Location loc = window.Location;
                     Debug.Assert(loc != null, "In handling the default action for Click Content Window location cannot be retrived!");
                     if (loc != null)
                     {
                         loc.Href = newHref;
                         Debug.WriteLine("Setting href of window location to {0}", newHref);
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 3
0
 public void BuildReferenceMap()
 {
     if (!(WrappedObject is PARAM.Row) && !(WrappedObject is MergedParamRow))
     {
         var type  = WrappedObject.GetType();
         var props = type.GetProperties(BindingFlags.Instance | BindingFlags.Public);
         foreach (var p in props)
         {
             var att = p.GetCustomAttribute <MSBReference>();
             if (att != null)
             {
                 if (p.PropertyType.IsArray)
                 {
                 }
                 else
                 {
                     var sref = (string)p.GetValue(WrappedObject);
                     if (sref != null && sref != "")
                     {
                         var obj = Container.GetObjectByName(sref);
                         if (obj != null)
                         {
                             References.Add(p.Name, new[] { obj });
                         }
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 4
0
        public T GetPropertyValue <T>(string prop)
        {
            if (WrappedObject == null)
            {
                return(default(T));
            }
            if (WrappedObject is PARAM.Row row)
            {
                var pp = row.Cells.FirstOrDefault(cell => cell.Def.InternalName == prop);
                if (pp != null)
                {
                    return((T)pp.Value);
                }
            }
            else if (WrappedObject is MergedParamRow mrow)
            {
                var pp = mrow[prop];
                if (pp != null)
                {
                    return((T)pp.Value);
                }
            }
            var p = WrappedObject.GetType().GetProperty(prop);

            if (p != null && p.PropertyType == typeof(T))
            {
                return((T)p.GetValue(WrappedObject, null));
            }
            return(default(T));
        }
Exemplo n.º 5
0
        public PropertyInfo GetProperty(string prop)
        {
            if (WrappedObject == null)
            {
                return(null);
            }
            if (WrappedObject is PARAM.Row row)
            {
                var pp = row[prop];
                if (pp != null)
                {
                    return(pp.GetType().GetProperty("Value"));
                }
            }
            else if (WrappedObject is MergedParamRow mrow)
            {
                var pp = mrow[prop];
                if (pp != null)
                {
                    return(pp.GetType().GetProperty("Value"));
                }
            }
            var p = WrappedObject.GetType().GetProperty(prop);

            if (p != null)
            {
                return(p);
            }
            return(null);
        }
Exemplo n.º 6
0
        public override bool TrySetMember(SetMemberBinder binder, object value)
        {
            MemberInfo memberInfo = ChoTypeMembersCache.GetMemberInfo(WrappedObject.GetType(), binder.Name);

            if (memberInfo == null)
            {
                return(false);
            }

            // Locate property by name
            var propertyInfo = memberInfo as PropertyInfo; // WrappedObject.GetType().GetProperty(binder.Name, BindingFlags.Instance | BindingFlags.Public | (binder.IgnoreCase ? BindingFlags.IgnoreCase : 0));

            if (propertyInfo != null && !propertyInfo.CanWrite)
            {
                return(false);
            }

            RaisePropertyChanging(binder.Name);

            ChoType.SetMemberValue(WrappedObject, memberInfo, value);

            //object newValue = value;
            //// Check the types are compatible
            //Type propertyType = propertyInfo.PropertyType;
            //if (!propertyType.IsAssignableFrom(value.GetType()))
            //{
            //    newValue = Convert.ChangeType(value, propertyType);
            //}

            //propertyInfo.SetValue(WrappedObject, newValue, null);
            RaisePropertyChanged(binder.Name);
            return(true);
        }
Exemplo n.º 7
0
        protected virtual void ConnectWrapped()
        {
            WrappedObject.AddNotification("id", NotifyIdHandler);

            if (WrappedObject is Cdn.Annotatable)
            {
                WrappedObject.AddNotification("annotation", NotifyAnnotationHandler);
            }

            WrappedObject.VariableAdded     += HandleVariableAdded;
            WrappedObject.VariableRemoved   += HandleVariableRemoved;
            WrappedObject.Copied            += HandleCopied;
            WrappedObject.TemplateApplied   += HandleTemplateApplied;
            WrappedObject.TemplateUnapplied += HandleTemplateUnapplied;

            if (WrappedObject.SupportsLocation())
            {
                AddLocationNotifification();

                Moved += delegate(object sender, EventArgs e) {
                    int x;
                    int y;

                    WrappedObject.GetLocation(out x, out y);

                    if ((int)Allocation.X != x || (int)Allocation.Y != y)
                    {
                        RemoveLocationNotification();
                        WrappedObject.SetLocation((int)Allocation.X, (int)Allocation.Y);
                        AddLocationNotifification();
                    }
                };
            }
        }
Exemplo n.º 8
0
        public static JSEvent createEvent(string eventClassString, WrappedObject target)
        {
            JSEvent      evt        = null;
            EventClasses eventClass = EventClasses.Event;

            if (eventClassString == "Event")
            {
                eventClass = EventClasses.Event;
            }
            else if (eventClassString == "UIEvent")
            {
                eventClass = EventClasses.UIEvent;
            }
            else if (eventClassString == "MouseEvent")
            {
                eventClass = EventClasses.MouseEvent;
            }
            else
            {
                //Throw Unsupported error exception according to W3C createEvent documentation
            }
            evt = new JSEvent();
            evt.InitializeCreatedEvent(eventClass, target);

            return(evt);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Register SendingRequest(2) event to inject authentication cookies.
        /// </summary>
        /// <param name="context">the WrappedDataServiceContext</param>
        public void RegisterSendingRequestEvent(WrappedObject context)
        {
            DataServiceContext ctx = context.Product as DataServiceContext;

            ExceptionUtilities.CheckObjectNotNull(ctx, "context has to be WrappedDataServiceContext.");
            // use SendingRequest2 since the client does not allow SendingRequest and BuildingRequest registered at the same time
            ctx.SendingRequest2 += this.InjectAuthenticationCookies;
        }
Exemplo n.º 10
0
 public override bool Equals(object obj)
 {
     if (obj is IObjectWrapperViewModel viewModel)
     {
         return(WrappedObject.Equals(viewModel.WrappedObject));
     }
     return(WrappedObject.Equals(obj));
 }
Exemplo n.º 11
0
 public Action GetUpdateTransformAction(Transform newt)
 {
     if (WrappedObject is PARAM.Row || WrappedObject is MergedParamRow)
     {
         var   actions = new List <Action>();
         float roty    = newt.EulerRotation.Y * Utils.Rad2Deg - 180.0f;
         actions.Add(GetPropertyChangeAction("PositionX", newt.Position.X));
         actions.Add(GetPropertyChangeAction("PositionY", newt.Position.Y));
         actions.Add(GetPropertyChangeAction("PositionZ", newt.Position.Z));
         actions.Add(GetPropertyChangeAction("RotationX", newt.EulerRotation.X * Utils.Rad2Deg));
         actions.Add(GetPropertyChangeAction("RotationY", roty));
         actions.Add(GetPropertyChangeAction("RotationZ", newt.EulerRotation.Z * Utils.Rad2Deg));
         var act = new CompoundAction(actions);
         act.SetPostExecutionAction((undo) =>
         {
             UpdateRenderModel();
         });
         return(act);
     }
     else
     {
         var act  = new PropertiesChangedAction(WrappedObject);
         var prop = WrappedObject.GetType().GetProperty("Position");
         act.AddPropertyChange(prop, newt.Position);
         prop = WrappedObject.GetType().GetProperty("Rotation");
         if (prop != null)
         {
             if (IsRotationPropertyRadians("Rotation"))
             {
                 if (IsRotationXZY("Rotation"))
                 {
                     act.AddPropertyChange(prop, newt.EulerRotationXZY);
                 }
                 else
                 {
                     act.AddPropertyChange(prop, newt.EulerRotation);
                 }
             }
             else
             {
                 if (IsRotationXZY("Rotation"))
                 {
                     act.AddPropertyChange(prop, newt.EulerRotationXZY * Utils.Rad2Deg);
                 }
                 else
                 {
                     act.AddPropertyChange(prop, newt.EulerRotation * Utils.Rad2Deg);
                 }
             }
         }
         act.SetPostExecutionAction((undo) =>
         {
             UpdateRenderModel();
         });
         return(act);
     }
 }
Exemplo n.º 12
0
        private void OnLocationChanged(object source, GLib.NotifyArgs args)
        {
            int x;
            int y;

            WrappedObject.GetLocation(out x, out y);

            Allocation.X = x;
            Allocation.Y = y;
        }
Exemplo n.º 13
0
 public bool IsRotationXZY(string prop)
 {
     if (WrappedObject == null)
     {
         return(false);
     }
     if (WrappedObject is PARAM.Row row || WrappedObject is MergedParamRow mrow)
     {
         return(false);
     }
     return(WrappedObject.GetType().GetProperty(prop).GetCustomAttribute <RotationXZY>() != null);
 }
Exemplo n.º 14
0
        public override PropertyDescriptorCollection GetProperties(Attribute[] attributes)
        {
            var properties = base.GetProperties(attributes).Cast <PropertyDescriptor>()
                             .Where(p => BrowsableProperties.Contains(p.Name))
                             .Select(p => TypeDescriptor.CreateProperty(
                                         WrappedObject.GetType(),
                                         p,
                                         p.Attributes.Cast <Attribute>().ToArray()))
                             .ToArray();

            return(new PropertyDescriptorCollection(properties));
        }
Exemplo n.º 15
0
 public int Add(WrappedObject dw)
 {
     if (freeIndeces.Count > 0) {
         int index = freeIndeces[0];
         System.Diagnostics.Debug.Assert(objectMap[index] == null);
         objectMap[index] = new WeakReference(dw);
         freeIndeces.RemoveAt(0);
         return index;
     } else {
         EnlargeMap();
         return (Add(dw));
     }
 }
Exemplo n.º 16
0
        public override bool TryGetMember(GetMemberBinder binder, out object result)
        {
            // Locate property by name
            var propertyInfo = WrappedObject.GetType().GetProperty(binder.Name, BindingFlags.Instance | BindingFlags.Public | (binder.IgnoreCase ? BindingFlags.IgnoreCase : 0));

            if (propertyInfo == null || !propertyInfo.CanRead)
            {
                result = null;
                return(false);
            }

            result = propertyInfo.GetValue(WrappedObject, null);
            return(true);
        }
Exemplo n.º 17
0
 public void InitializeCreatedEvent(EventClasses eventClass, WrappedObject target)
 {
     Data.EventClass  = eventClass;
     Data.Type        = EventTypes.ZoommInvalid;
     Data.Target      = target;
     CurrentTarget    = target;
     Bubbles          = false;
     Cancelable       = true;
     DefaultPrevented = false;
     IsTrusted        = false;
     Phase            = Phases.AtTarget;
     InitializeEventFlags();
     UpdateMap();
 }
Exemplo n.º 18
0
 public int Add(WrappedObject dw)
 {
     if (freeIndeces.Count > 0)
     {
         int index = freeIndeces[0];
         System.Diagnostics.Debug.Assert(objectMap[index] == null);
         objectMap[index] = new WeakReference(dw);
         freeIndeces.RemoveAt(0);
         return(index);
     }
     else
     {
         EnlargeMap();
         return(Add(dw));
     }
 }
Exemplo n.º 19
0
        public virtual void UpdateRenderModel()
        {
            if (!HasTransform)
            {
                return;
            }
            Matrix4x4 t = UseTempTransform ? TempTransform.WorldMatrix : GetLocalTransform().WorldMatrix;
            var       p = Parent;

            while (p != null)
            {
                t = t * (p.UseTempTransform ? p.TempTransform.WorldMatrix : p.GetLocalTransform().WorldMatrix);
                p = p.Parent;
            }
            if (RenderSceneMesh != null)
            {
                RenderSceneMesh.World = t;
            }
            foreach (var c in Children)
            {
                if (c.HasTransform)
                {
                    c.UpdateRenderModel();
                }
            }

            if (UseDrawGroups)
            {
                var prop = WrappedObject.GetType().GetProperty("DrawGroups");
                if (prop != null && RenderSceneMesh != null)
                {
                    RenderSceneMesh.DrawGroups.AlwaysVisible = false;
                    RenderSceneMesh.DrawGroups.Drawgroups    = (uint[])prop.GetValue(WrappedObject);
                }
            }

            if (RenderSceneMesh != null)
            {
                RenderSceneMesh.Visible = _EditorVisible;
            }
        }
Exemplo n.º 20
0
        static SampleDOMNode()
        {
            //Here we build the prototype of DOM Object Wrapper. This prototype must have all
            //the methods of the DOM object callable by JS.
            prototype = new mdr.DObject();
            prototype.SetField("GetElementByName", new mdr.DFunction((ref mdr.CallFrame callFrame) =>
            {
                var o      = callFrame.This as WrappedObject;
                var domptr = o.Domptr;

                //GCHandle gchWrapperIndex = GCHandle.Alloc(new int(), GCHandleType.Pinned);
                var elemName = callFrame.Arg0.ToString();

                WrappedObject elemPtr = GetElementByName(domptr, /*gchWrapperIndex.AddrOfPinnedObject(),*/ elemName) as WrappedObject;

                //int wrapperindex = (int)gchWrapperIndex.Target;
                //gchWrapperIndex.Free();

                callFrame.Return.Set(elemPtr);
            }));

            prototype.SetField("GetName", new mdr.DFunction((ref mdr.CallFrame callFrame) =>
            {
                var o    = callFrame.This as WrappedObject;
                var arg0 = o.Domptr;
                callFrame.Return.Set(GetName(arg0));
            }));

            prototype.SetField("Num", new mdr.DProperty()
            {
                TargetValueType = mdr.ValueTypes.Int32,
                OnGetInt        = (This) =>
                {
                    Console.WriteLine("running getNum in C#");
                    Console.Out.Flush();
                    return(GetNum(((WrappedObject)This).Domptr));
                },
                OnSetInt    = (This, n) => SetNum(((WrappedObject)This).Domptr, n),
                OnGetDValue = (mdr.DObject This, ref mdr.DValue v) => { v.Set(GetNum(((WrappedObject)This).Domptr)); },
            });
        }
Exemplo n.º 21
0
        protected virtual void DisconnectWrapped()
        {
            WrappedObject.RemoveNotification("id", NotifyIdHandler);

            if (WrappedObject is Cdn.Annotatable)
            {
                WrappedObject.RemoveNotification("annotation", NotifyAnnotationHandler);
            }

            WrappedObject.VariableAdded   -= HandleVariableAdded;
            WrappedObject.VariableRemoved -= HandleVariableRemoved;
            WrappedObject.Copied          -= HandleCopied;

            WrappedObject.TemplateApplied   -= HandleTemplateApplied;
            WrappedObject.TemplateUnapplied -= HandleTemplateUnapplied;

            if (WrappedObject.SupportsLocation())
            {
                RemoveLocationNotification();
            }
        }
Exemplo n.º 22
0
 public Wrappers.Edge GetActionTemplate(Cdn.EdgeAction action, bool match_full)
 {
     return((Wrappers.Edge)Wrapper.Wrap(WrappedObject.GetActionTemplate(action, match_full)));
 }
Exemplo n.º 23
0
 public override IEnumerable <string> GetDynamicMemberNames()
 {
     return(from f in WrappedObject.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public)
            select f.Name);
 }
Exemplo n.º 24
0
 public Cdn.EdgeAction GetAction(string target)
 {
     return(WrappedObject.GetAction(target));
 }
Exemplo n.º 25
0
 public bool RemoveAction(Cdn.EdgeAction action)
 {
     return(WrappedObject.RemoveAction(action));
 }
Exemplo n.º 26
0
 /// <summary>
 /// Wraps the 'Void CopyTo(System.Array, Int32)' on the 'System.Collections.ICollection' type.
 /// </summary>
 /// <param name="array">The value of the 'array' parameter.</param>
 /// <param name="index">The value of the 'index' parameter.</param>
 public virtual void CopyTo(WrappedObject array, int index)
 {
     WrapperUtilities.InvokeMethodWithoutResult(this, WrapperUtilities.GetMethodInfo(WrappedObjectType, MethodInfoCache, "Void CopyTo(System.Array, Int32)"), new object[] { array, index });
 }
Exemplo n.º 27
0
 public bool AddAction(Cdn.EdgeAction action)
 {
     return(WrappedObject.AddAction(action));
 }
Exemplo n.º 28
0
 public override int GetHashCode()
 {
     return(WrappedObject.GetHashCode());
 }
Exemplo n.º 29
0
 public override string ToString()
 {
     return(WrappedObject.ToString());
 }
Exemplo n.º 30
0
		public static WrappedObject MakeWrapper(IntPtr domptr)
		{
		    WrappedObject wrapper = new WrappedObject(domptr, prototype);
  			return wrapper;
		}
Exemplo n.º 31
0
 /// <summary>
 /// Set stream associated with entity in V1 stream support style.
 /// </summary>
 /// <param name="objectServices">IEntityModelObjectServices to get entity object adapter</param>
 /// <param name="wrappedEntity">entity to set stream</param>
 /// <param name="clientMediaEntryAnnotation">ClientMediaEntryAnnotation of the entity</param>
 /// <param name="streamValue">stream bytes</param>
 public static void SetSaveV1Stream(IEntityModelObjectServices objectServices, WrappedObject wrappedEntity, ClientMediaEntryAnnotation clientMediaEntryAnnotation, byte[] streamValue)
 {
     var objectAdapter = objectServices.GetObjectAdapter(wrappedEntity.Product.GetType().FullName);
     objectAdapter.SetMemberValue(wrappedEntity.Product, clientMediaEntryAnnotation.MediaEntryName, streamValue);
     objectAdapter.SetMemberValue(wrappedEntity.Product, clientMediaEntryAnnotation.MimeTypePropertyName, MimeTypes.TextPlain);
 }
Exemplo n.º 32
0
        /// <summary>
        /// Register SendingRequest(2) event to inject authentication cookies.
        /// </summary>
        /// <param name="context">the WrappedDataServiceContext</param>
        public void RegisterSendingRequestEvent(WrappedObject context)
        {
            DataServiceContext ctx = context.Product as DataServiceContext;
            ExceptionUtilities.CheckObjectNotNull(ctx, "context has to be WrappedDataServiceContext.");
#if WINDOWS_PHONE
            ctx.SendingRequest += this.InjectAuthenticationCookies;
#else
            // use SendingRequest2 since the client does not allow SendingRequest and BuildingRequest registered at the same time
            ctx.SendingRequest2 += this.InjectAuthenticationCookies;
#endif
        }
Exemplo n.º 33
0
        public object this[string fieldName]
        {
            get
            {
                if (Fields.TryGetValue(fieldName, out var field))
                {
                    return(field.Get(WrappedObject));
                }

                else
                {
                    throw new MissingFieldException("Field " + fieldName + " does not exist in Type " + WrappedObject.GetType());
                }
            }
            set
            {
                if (Fields.TryGetValue(fieldName, out var field))
                {
                    field.Set(WrappedObject, value);
                }

                else
                {
                    throw new MissingFieldException("Field " + fieldName + " does not exist in Type " + WrappedObject.GetType());
                }
            }
        }
Exemplo n.º 34
0
 /// <summary>
 /// Wraps the 'System.IAsyncResult BeginExecute(System.AsyncCallback, System.Object)' on the 'Microsoft.OData.Client.DataServiceQuery`1' type.
 /// </summary>
 /// <param name="callback">The value of the 'callback' parameter.</param>
 /// <param name="state">The value of the 'state' parameter.</param>
 /// <returns>The value returned by the underlying method.</returns>
 public new virtual System.IAsyncResult BeginExecute(System.AsyncCallback callback, WrappedObject state)
 {
     return(WrapperUtilities.InvokeMethodAndCast <System.IAsyncResult>(this, AstoriaWrapperUtilities.GetMethodInfo(WrappedObjectType, MethodInfoCache, "System.IAsyncResult BeginExecute(System.AsyncCallback, System.Object)"), new object[] { callback, state }));
 }
Exemplo n.º 35
0
 /// <summary>
 /// Wraps the 'Microsoft.OData.Client.DataServiceQuery`1[TElement] AddQueryOption(System.String, System.Object)' on the 'Microsoft.OData.Client.DataServiceQuery`1' type.
 /// </summary>
 /// <param name="name">The value of the 'name' parameter.</param>
 /// <param name="value">The value of the 'value' parameter.</param>
 /// <returns>The value returned by the underlying method.</returns>
 public virtual WrappedDataServiceQuery <TElement> AddQueryOption(string name, WrappedObject value)
 {
     return(WrapperUtilities.InvokeMethodAndWrap <WrappedDataServiceQuery <TElement> >(this, AstoriaWrapperUtilities.GetMethodInfo(WrappedObjectType, MethodInfoCache, "Microsoft.OData.Client.DataServiceQuery`1[TElement] AddQueryOption(System.String, System.Object)"), new object[] { name, value }));
 }
Exemplo n.º 36
0
 /// <summary>
 /// Wraps the 'System.IAsyncResult BeginExecute(System.AsyncCallback, System.Object)' on the 'Microsoft.OData.Client.DataServiceQuery' type.
 /// </summary>
 /// <param name="callback">The value of the 'callback' parameter.</param>
 /// <param name="state">The value of the 'state' parameter.</param>
 /// <returns>The value returned by the underlying method.</returns>
 public virtual System.IAsyncResult BeginExecute(System.AsyncCallback callback, WrappedObject state)
 {
     return WrapperUtilities.InvokeMethodAndCast<System.IAsyncResult>(this, AstoriaWrapperUtilities.GetMethodInfo(WrappedObjectType, MethodInfoCache, "System.IAsyncResult BeginExecute(System.AsyncCallback, System.Object)"), new object[] { callback, state });
 }