コード例 #1
0
        protected override void OnAttached()
        {
            base.OnAttached();

            m_appliedSample = null;
            m_subscriptions = SeeingSharpApplication.Current.UIMessenger.SubscribeAll(this);
        }
コード例 #2
0
ファイル: BaseDefinition.cs プロジェクト: frikst/SharpDiffLib
        public void OneReplacedWithOtherDescendant()
        {
            var @base = new SampleBase[]
            {
                new SampleDescendant1 {
                    Id = 1, Value = "a"
                },
                new SampleDescendant1 {
                    Id = 2, Value = "b"
                }
            };
            var changed = new SampleBase[]
            {
                new SampleDescendant1 {
                    Id = 1, Value = "a"
                },
                new SampleDescendant2 {
                    Id = 2, Value = "b"
                }
            };

            var expected = DiffFactory.Create <SampleBase[]>().Ordered()
                           .Changed(1, inner => inner.Value()
                                    .Replaced(new SampleDescendant1 {
                Id = 2, Value = "b"
            }, new SampleDescendant2 {
                Id = 2, Value = "b"
            })
                                    )
                           .MakeDiff();

            var ret = Merger.Instance.Partial.Diff(@base, changed);

            Assert.AreEqual(expected, ret);
        }
コード例 #3
0
        public void SetSample(SampleBase newSample)
        {
            // clean up the old sample
            if (sample != null)
            {
                sample.RefreshRequested -= OnRefreshRequested;
                sample.Destroy();
            }

            sample = newSample;

            // set the title
            var title = sample?.Title ?? "SkiaSharp for MacOS";

            Title = title;
            var window = View?.Window;

            if (window != null)
            {
                window.Title = title;
            }

            // prepare the sample
            if (sample != null)
            {
                sample.RefreshRequested += OnRefreshRequested;
                sample.Init();
            }

            // refresh the view
            OnRefreshRequested(null, null);
        }
コード例 #4
0
        public void OneChangedProperty()
        {
            var diff = DiffFactory.Create <SampleBase[]>().Ordered()
                       .Changed(1, inner => inner.Value()
                                .ChangedType <SampleDescendant1>(inner2 => inner2.Class()
                                                                 .Replaced(x => x.Value, "b", "c")
                                                                 )
                                )
                       .MakeDiff();

            var obj = new SampleBase[]
            {
                new SampleDescendant1 {
                    Id = 1, Value = "a"
                },
                new SampleDescendant1 {
                    Id = 2, Value = "b"
                }
            };
            var changed = new SampleBase[]
            {
                new SampleDescendant1 {
                    Id = 1, Value = "a"
                },
                new SampleDescendant1 {
                    Id = 2, Value = "c"
                }
            };

            var ret = Merger.Instance.Partial.ApplyPatch(obj, diff);

            CollectionAssert.AreEqual(changed, ret);
        }
コード例 #5
0
        public void Setup(SampleSelectorUI parentUI, SampleBase prefab)
        {
            this.ParentUI      = parentUI;
            this.ExamplePrefab = prefab;

            this._text.text = prefab.DisplayName;
        }
コード例 #6
0
    static void CreateExportPlan(GameObject go,
                                 SampleBase sample,
                                 ExportFunction exportFunc,
                                 ExportContext context,
                                 string pathSuffix = null,
                                 object data = null,
                                 bool insertFirst = true) {
      // This is an exportable object.
      Transform expRoot = context.exportRoot;
      string path = UnityTypeConverter.GetPath(go.transform, expRoot);
      if (!string.IsNullOrEmpty(pathSuffix)) {
        path += pathSuffix;
      }
      if (!context.plans.ContainsKey(go)) {
        context.plans.Add(go, new ExportPlan());
      }

      var exp = new Exporter { exportFunc = exportFunc, sample = sample, path = path, data = data };
      if (insertFirst) {
        context.plans[go].exporters.Insert(0, exp);
      } else {
        context.plans[go].exporters.Add(exp);
      }

      // Include the parent xform hierarchy.
      // Note that the parent hierarchy is memoised, so despite looking expensive, the time
      // complexity is linear.
      Transform xf = go.transform.parent;
      if (xf != context.exportRoot && !context.plans.ContainsKey(xf.gameObject)) {
        // Since all GameObjects have a Transform, export all un-exported parents as transform.
        CreateExportPlan(xf.gameObject, CreateSample<XformSample>(context), XformExporter.ExportXform, context);
        CreateExportPlan(xf.gameObject, CreateSample<XformSample>(context), NativeExporter.ExportObject, context, insertFirst: false);
      }
    }
コード例 #7
0
ファイル: BaseDefinition.cs プロジェクト: frikst/SharpDiffLib
        public void OneChangedProperty()
        {
            var @base = new SampleBase[]
            {
                new SampleDescendant1 {
                    Id = 1, Value = "a"
                },
                new SampleDescendant1 {
                    Id = 2, Value = "b"
                }
            };
            var changed = new SampleBase[]
            {
                new SampleDescendant1 {
                    Id = 1, Value = "a"
                },
                new SampleDescendant1 {
                    Id = 2, Value = "c"
                }
            };

            var expected = DiffFactory.Create <SampleBase[]>().Ordered()
                           .Changed(1, inner => inner.Value()
                                    .ChangedType <SampleDescendant1>(inner2 => inner2.Class()
                                                                     .Replaced(x => x.Value, "b", "c")
                                                                     )
                                    )
                           .MakeDiff();

            var ret = Merger.Instance.Partial.Diff(@base, changed);

            Assert.AreEqual(expected, ret);
        }
コード例 #8
0
        public void OneAdded()
        {
            var diff = DiffFactory.Create <SampleBase[]>().Ordered()
                       .Added(1, new SampleDescendant1 {
                Id = 2, Value = "b"
            })
                       .MakeDiff();

            var obj = new SampleBase[]
            {
                new SampleDescendant1 {
                    Id = 1, Value = "a"
                }
            };
            var changed = new SampleBase[]
            {
                new SampleDescendant1 {
                    Id = 1, Value = "a"
                },
                new SampleDescendant1 {
                    Id = 2, Value = "b"
                }
            };

            var ret = Merger.Instance.Partial.ApplyPatch(obj, diff);

            CollectionAssert.AreEqual(changed, ret);
        }
コード例 #9
0
ファイル: BaseDefinition.cs プロジェクト: frikst/SharpDiffLib
        public void OneAdded()
        {
            var @base = new SampleBase[]
            {
                new SampleDescendant1 {
                    Id = 1, Value = "a"
                }
            };
            var changed = new SampleBase[]
            {
                new SampleDescendant1 {
                    Id = 1, Value = "a"
                },
                new SampleDescendant1 {
                    Id = 2, Value = "b"
                }
            };

            var expected = DiffFactory.Create <SampleBase[]>().Ordered()
                           .Added(1, new SampleDescendant1 {
                Id = 2, Value = "b"
            })
                           .MakeDiff();

            var ret = Merger.Instance.Partial.Diff(@base, changed);

            Assert.AreEqual(expected, ret);
        }
コード例 #10
0
        //private SKImage lastImage;

        public DetailContentsPage(SampleBase showcase)
        {
            InitializeComponent();

            Sample         = showcase;
            BindingContext = this;
        }
コード例 #11
0
        public void SetSample(SampleBase newSample)
        {
            sample = newSample;

            // set the title
            var title = sample?.Title ?? "SkiaSharp for MacOS";

            Title = title;
            var window = View?.Window;

            if (window != null)
            {
                window.Title = title;
            }

            // prepare the sample
            sample?.Init(() =>
            {
                // refresh the view
                canvas.SetNeedsDisplayInRect(canvas.Bounds);
                glview.SetNeedsDisplayInRect(glview.Bounds);
            });

            // refresh the view
            canvas.SetNeedsDisplayInRect(canvas.Bounds);
            glview.SetNeedsDisplayInRect(glview.Bounds);
        }
コード例 #12
0
 public void ExecuteExample(SampleBase example)
 {
     if (this.dynamicContent != null)
     {
         Destroy(this.dynamicContent);
     }
     this.dynamicContent = Instantiate(example, this._dyncamicContentRoot, false).gameObject;
 }
コード例 #13
0
ファイル: ExampleInfo.cs プロジェクト: arvindixonos/Zain360
        public void Setup(SampleSelectorUI parentUI, SampleBase example)
        {
            this._parentUI = parentUI;
            this._example  = example;

            this._header.text      = this._example.name;
            this._description.text = this._example.Description;
        }
コード例 #14
0
        private void OnSampleSelected(SampleBase sample)
        {
            // update the selected sample
            currentSample = sample;
            currentSample?.Init(canvas.SetNeedsDisplay);

            // refresh the canvas
            canvas.SetNeedsDisplay();
        }
コード例 #15
0
ファイル: SubClass.cs プロジェクト: frikst/SharpDiffLib
        public void ChangedType()
        {
            SampleBase @base = new SampleDescendant1();
            SampleBase left  = new SampleDescendant1();
            SampleBase right = new SampleDescendant2();

            SampleBase ret = Merger.Instance.Merge(@base, left, right);

            Assert.IsInstanceOf <SampleDescendant2>(ret);
        }
コード例 #16
0
        public void TestGetFieldValue()
        {
            SampleBase sampleObj = new SampleBase();

            Assert.AreEqual(sampleObj.MyString, ReflectionUtil.GetFieldValue(sampleObj, "MyString"));
            Assert.AreEqual(sampleObj.MyInt, ReflectionUtil.GetFieldValue(sampleObj, "MyInt"));
            Assert.AreEqual(sampleObj.MyFloat, ReflectionUtil.GetFieldValue(sampleObj, "MyFloat"));
            Assert.AreEqual(sampleObj.MyList, ReflectionUtil.GetFieldValue(sampleObj, "MyList"));
            Assert.AreEqual(sampleObj.MyList[2], ReflectionUtil.GetFieldValue(sampleObj, "MyList", 2));
        }
コード例 #17
0
        public void AddPoint(Vector2 screenPos, GameObject markerPrefab)
        {
            Vector3 pos = SampleBase.GetWorldPos(screenPos);

            if (markerPrefab)
            {
                AddMarker(pos, markerPrefab);
            }

            points.Add(pos);
            UpdateLines();
        }
コード例 #18
0
ファイル: SubClass.cs プロジェクト: frikst/SharpDiffLib
        public void ChangedTypeWithConflict()
        {
            SampleBase @base = new SampleDescendant1();
            SampleBase left  = new SampleDescendant1 {
                Value = "a"
            };
            SampleBase right = new SampleDescendant2();

            SampleBase ret = Merger.Instance.Merge(@base, left, right);

            Assert.IsInstanceOf <SampleDescendant1>(ret);
            Assert.AreEqual("a", ((SampleDescendant1)ret).Value);
        }
コード例 #19
0
        /// <summary>
        /// Attaches the specified associated object.
        /// </summary>
        /// <param name="associatedObject">The associated object.</param>
        public void Attach(DependencyObject associatedObject)
        {
            m_associatedObject = associatedObject;
            m_appliedSample    = null;
            m_subscriptions    = SeeingSharpApplication.Current.UIMessenger.SubscribeAll(this);

            SwapChainPanel renderElement = m_associatedObject as SwapChainPanel;

            if (renderElement != null)
            {
                m_painter.Attach(renderElement);
            }
        }
コード例 #20
0
        public static SampleBase GetSampleBase()
        {
            SampleBase sampleBase = new SampleBase();

            sampleBase.TextValue   = Guid.NewGuid().ToString();
            sampleBase.NumberValue = TestCaseUtils._rnd.Next();
            int num  = TestCaseUtils._rnd.Next();
            int num2 = TestCaseUtils._rnd.Next();
            int num3 = TestCaseUtils._rnd.Next();

            sampleBase.VectorValue = new Vector3((float)num, (float)num2, (float)num3);
            return(sampleBase);
        }
コード例 #21
0
        void InitExportableObjects(GameObject go)
        {
            SampleBase     sample     = null;
            ExportFunction exportFunc = null;

            if (go.GetComponent <MeshFilter>() != null && go.GetComponent <MeshRenderer>() != null)
            {
                sample     = new MeshSample();
                exportFunc = ExportMesh;
                foreach (var mat in go.GetComponent <MeshRenderer>().materials)
                {
                    if (!m_materialMap.ContainsKey(mat))
                    {
                        string usdPath = "/World/Materials/" + pxr.UsdCs.TfMakeValidIdentifier(mat.name);
                        m_materialMap.Add(mat, usdPath);
                    }
                }
            }
            else if (go.GetComponent <Camera>())
            {
                sample     = new CameraSample();
                exportFunc = ExportCamera;
            }
            else
            {
                return;
            }

            // This is an exportable object.
            string path = Unity.UnityTypeConverter.GetPath(go.transform);

            m_primMap.Add(go, new ExportPlan {
                path = path, sample = sample, exportFunc = exportFunc
            });
            Debug.Log(path + " " + sample.GetType().Name);

            // Include the parent xform hierarchy.
            // Note that the parent hierarchy is memoised, so despite looking expensive, the time
            // complexity is linear.
            Transform xf = go.transform.parent;

            while (xf)
            {
                if (!InitExportableParents(xf.gameObject))
                {
                    break;
                }
                xf = xf.parent;
            }
        }
コード例 #22
0
        public static SampleBase GetSampleBase()
        {
            var sb = new SampleBase();

            sb.TextValue   = Guid.NewGuid().ToString();
            sb.NumberValue = _rnd.Next();

            var x = _rnd.Next();
            var y = _rnd.Next();
            var z = _rnd.Next();

            sb.VectorValue = new Vector3((float)x, (float)y, (float)z);

            return(sb);
        }
コード例 #23
0
 public void DictionaryObjectKeySerialization()
 {
     this.LogStart("Dictionary (Object As Key)");
     try
     {
         Dictionary <SampleBase, int> dictionary = new Dictionary <SampleBase, int>();
         for (int i = 0; i < 4; i++)
         {
             dictionary.Add(TestCaseUtils.GetSampleBase(), i);
         }
         string text = JsonConvert.SerializeObject(dictionary);
         this.LogSerialized(text);
         this._text.set_text(text);
         Dictionary <SampleBase, int> dictionary2 = JsonConvert.DeserializeObject <Dictionary <SampleBase, int> >(text);
         List <SampleBase>            list        = new List <SampleBase>();
         List <SampleBase>            list2       = new List <SampleBase>();
         using (Dictionary <SampleBase, int> .KeyCollection.Enumerator enumerator = dictionary.get_Keys().GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 SampleBase current = enumerator.get_Current();
                 list.Add(current);
             }
         }
         using (Dictionary <SampleBase, int> .KeyCollection.Enumerator enumerator2 = dictionary2.get_Keys().GetEnumerator())
         {
             while (enumerator2.MoveNext())
             {
                 SampleBase current2 = enumerator2.get_Current();
                 list2.Add(current2);
             }
         }
         this.LogResult(list.get_Item(1).TextValue, list2.get_Item(1).TextValue);
         if (list.get_Item(1).TextValue != list2.get_Item(1).TextValue)
         {
             this.DisplayFail("Dictionary (Object As Key)", "Incorrect Deserialized Result");
         }
         else
         {
             this.DisplaySuccess("Dictionary (Object As Key)");
         }
     }
     catch (Exception ex)
     {
         this.DisplayFail("Dictionary (Object As Key)", ex.get_Message());
         throw;
     }
 }
コード例 #24
0
 /// <summary>
 /// Dispose pattern.
 /// </summary>
 /// <param name="disposing">
 /// True if being called from Dispose, false if from the finalizer.
 /// </param>
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (SampleFraction != null)
         {
             SampleFraction.Dispose();
             SampleFraction = null;
         }
         if (SampleBase != null)
         {
             SampleBase.Dispose();
             SampleBase = null;
         }
     }
 }
コード例 #25
0
        public void TestIgnoredDifferent()
        {
            var @base = new SampleBase {
                Value = "one", Value2 = "three"
            };
            var changed = new SampleBase {
                Value = "two", Value2 = "three"
            };

            var expected = DiffFactory.Create <SampleBase>().Class()
                           .MakeDiff();

            var ret = Merger.Instance.Partial.Diff(@base, changed);

            Assert.AreEqual(expected, ret);
        }
コード例 #26
0
        public void TestProcessedDifferent()
        {
            var @base = new SampleBase {
                Value = "one", Value2 = "three"
            };
            var changed = new SampleBase {
                Value = "one", Value2 = "four"
            };

            var expected = DiffFactory.Create <SampleBase>().Class()
                           .Replaced(x => x.Value2, "three", "four")
                           .MakeDiff();

            var ret = Merger.Instance.Partial.Diff(@base, changed);

            Assert.AreEqual(expected, ret);
        }
コード例 #27
0
ファイル: MainWindow.xaml.cs プロジェクト: gramland/SkiaSharp
        private void SetSample(SampleBase newSample)
        {
            sample = newSample;

            // set the title
            Title = sample?.Title ?? "SkiaSharp for WPF";

            // prepare the sample
            sample?.Init(() =>
            {
                // refresh the view
                canvas.InvalidateVisual();
                glhost.Child?.Invalidate();
            });

            // refresh the view
            canvas.InvalidateVisual();
            glhost.Child?.Invalidate();
        }
コード例 #28
0
ファイル: Form1.cs プロジェクト: gramland/SkiaSharp
        private void SetSample(SampleBase newSample)
        {
            sample = newSample;

            // set the title
            Text = sample?.Title ?? "SkiaSharp for Windows";

            // prepare the sample
            sample?.Init(() =>
            {
                // refresh the view
                canvas.Invalidate();
                glview.Invalidate();
            });

            // refresh the view
            canvas.Invalidate();
            glview.Invalidate();
        }
コード例 #29
0
        private TreeNode CreateTreeNode(SampleBase sample, int level)
        {
            TreeNode node = new TreeNode(sample.Title);

            node.Tag = sample;
            SampleGroup sg = sample as SampleGroup;

            if (sg != null)
            {
                foreach (SampleBase sb in sg.Children)
                {
                    node.Nodes.Add(CreateTreeNode(sb, level + 1));
                }
                node.ImageKey = node.SelectedImageKey = "BookClosed";
            }
            else
            {
                node.ImageKey = node.SelectedImageKey = "Item";
            }
            return(node);
        }
コード例 #30
0
        private void OnSampleSelected(SampleBase sample)
        {
            // clean up the old sample
            if (currentSample != null)
            {
                currentSample.RefreshRequested -= OnRefreshRequested;
                currentSample.Destroy();
            }

            // update the selected sample
            currentSample = sample;

            // prepare the sample
            if (sample != null)
            {
                sample.RefreshRequested += OnRefreshRequested;
                sample.Init();
            }

            // refresh the view
            OnRefreshRequested(null, null);
        }