Provides a type converter to convert globally unique identifier objects to and from various other representations.

Inheritance: TypeConverter
Esempio n. 1
1
        // Code compiled into PresentationFramework.dll

        // Initialize known object types
        internal static object CreateKnownElement(KnownElements knownElement) 
        {
            object o = null; 
            switch (knownElement) 
            {
                case KnownElements.AccessText: o = new System.Windows.Controls.AccessText();   break; 
                case KnownElements.AdornedElementPlaceholder: o = new System.Windows.Controls.AdornedElementPlaceholder();   break;
                case KnownElements.AdornerDecorator: o = new System.Windows.Documents.AdornerDecorator();   break;
                case KnownElements.AmbientLight: o = new System.Windows.Media.Media3D.AmbientLight();   break;
                case KnownElements.Application: o = new System.Windows.Application();   break; 
                case KnownElements.ArcSegment: o = new System.Windows.Media.ArcSegment();   break;
                case KnownElements.ArrayExtension: o = new System.Windows.Markup.ArrayExtension();   break; 
                case KnownElements.AxisAngleRotation3D: o = new System.Windows.Media.Media3D.AxisAngleRotation3D();   break; 
                case KnownElements.BeginStoryboard: o = new System.Windows.Media.Animation.BeginStoryboard();   break;
                case KnownElements.BevelBitmapEffect: o = new System.Windows.Media.Effects.BevelBitmapEffect();   break; 
                case KnownElements.BezierSegment: o = new System.Windows.Media.BezierSegment();   break;
                case KnownElements.Binding: o = new System.Windows.Data.Binding();   break;
                case KnownElements.BitmapEffectCollection: o = new System.Windows.Media.Effects.BitmapEffectCollection();   break;
                case KnownElements.BitmapEffectGroup: o = new System.Windows.Media.Effects.BitmapEffectGroup();   break; 
                case KnownElements.BitmapEffectInput: o = new System.Windows.Media.Effects.BitmapEffectInput();   break;
                case KnownElements.BitmapImage: o = new System.Windows.Media.Imaging.BitmapImage();   break; 
                case KnownElements.BlockUIContainer: o = new System.Windows.Documents.BlockUIContainer();   break; 
                case KnownElements.BlurBitmapEffect: o = new System.Windows.Media.Effects.BlurBitmapEffect();   break;
                case KnownElements.BmpBitmapEncoder: o = new System.Windows.Media.Imaging.BmpBitmapEncoder();   break; 
                case KnownElements.Bold: o = new System.Windows.Documents.Bold();   break;
                case KnownElements.BoolIListConverter: o = new System.Windows.Media.Converters.BoolIListConverter();   break;
                case KnownElements.BooleanAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.BooleanAnimationUsingKeyFrames();   break;
                case KnownElements.BooleanConverter: o = new System.ComponentModel.BooleanConverter();   break; 
                case KnownElements.BooleanKeyFrameCollection: o = new System.Windows.Media.Animation.BooleanKeyFrameCollection();   break;
                case KnownElements.BooleanToVisibilityConverter: o = new System.Windows.Controls.BooleanToVisibilityConverter();   break; 
                case KnownElements.Border: o = new System.Windows.Controls.Border();   break; 
                case KnownElements.BorderGapMaskConverter: o = new System.Windows.Controls.BorderGapMaskConverter();   break;
                case KnownElements.BrushConverter: o = new System.Windows.Media.BrushConverter();   break; 
                case KnownElements.BulletDecorator: o = new System.Windows.Controls.Primitives.BulletDecorator();   break;
                case KnownElements.Button: o = new System.Windows.Controls.Button();   break;
                case KnownElements.ByteAnimation: o = new System.Windows.Media.Animation.ByteAnimation();   break;
                case KnownElements.ByteAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.ByteAnimationUsingKeyFrames();   break; 
                case KnownElements.ByteConverter: o = new System.ComponentModel.ByteConverter();   break;
                case KnownElements.ByteKeyFrameCollection: o = new System.Windows.Media.Animation.ByteKeyFrameCollection();   break; 
                case KnownElements.Canvas: o = new System.Windows.Controls.Canvas();   break; 
                case KnownElements.CharAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.CharAnimationUsingKeyFrames();   break;
                case KnownElements.CharConverter: o = new System.ComponentModel.CharConverter();   break; 
                case KnownElements.CharIListConverter: o = new System.Windows.Media.Converters.CharIListConverter();   break;
                case KnownElements.CharKeyFrameCollection: o = new System.Windows.Media.Animation.CharKeyFrameCollection();   break;
                case KnownElements.CheckBox: o = new System.Windows.Controls.CheckBox();   break;
                case KnownElements.CollectionContainer: o = new System.Windows.Data.CollectionContainer();   break; 
                case KnownElements.CollectionViewSource: o = new System.Windows.Data.CollectionViewSource();   break;
                case KnownElements.Color: o = new System.Windows.Media.Color();   break; 
                case KnownElements.ColorAnimation: o = new System.Windows.Media.Animation.ColorAnimation();   break; 
                case KnownElements.ColorAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.ColorAnimationUsingKeyFrames();   break;
                case KnownElements.ColorConvertedBitmap: o = new System.Windows.Media.Imaging.ColorConvertedBitmap();   break; 
                case KnownElements.ColorConvertedBitmapExtension: o = new System.Windows.ColorConvertedBitmapExtension();   break;
                case KnownElements.ColorConverter: o = new System.Windows.Media.ColorConverter();   break;
                case KnownElements.ColorKeyFrameCollection: o = new System.Windows.Media.Animation.ColorKeyFrameCollection();   break;
                case KnownElements.ColumnDefinition: o = new System.Windows.Controls.ColumnDefinition();   break; 
                case KnownElements.CombinedGeometry: o = new System.Windows.Media.CombinedGeometry();   break;
                case KnownElements.ComboBox: o = new System.Windows.Controls.ComboBox();   break; 
                case KnownElements.ComboBoxItem: o = new System.Windows.Controls.ComboBoxItem();   break; 
                case KnownElements.CommandConverter: o = new System.Windows.Input.CommandConverter();   break;
                case KnownElements.ComponentResourceKey: o = new System.Windows.ComponentResourceKey();   break; 
                case KnownElements.ComponentResourceKeyConverter: o = new System.Windows.Markup.ComponentResourceKeyConverter();   break;
                case KnownElements.Condition: o = new System.Windows.Condition();   break;
                case KnownElements.ContainerVisual: o = new System.Windows.Media.ContainerVisual();   break;
                case KnownElements.ContentControl: o = new System.Windows.Controls.ContentControl();   break; 
                case KnownElements.ContentElement: o = new System.Windows.ContentElement();   break;
                case KnownElements.ContentPresenter: o = new System.Windows.Controls.ContentPresenter();   break; 
                case KnownElements.ContextMenu: o = new System.Windows.Controls.ContextMenu();   break; 
                case KnownElements.Control: o = new System.Windows.Controls.Control();   break;
                case KnownElements.ControlTemplate: o = new System.Windows.Controls.ControlTemplate();   break; 
                case KnownElements.CornerRadius: o = new System.Windows.CornerRadius();   break;
                case KnownElements.CornerRadiusConverter: o = new System.Windows.CornerRadiusConverter();   break;
                case KnownElements.CroppedBitmap: o = new System.Windows.Media.Imaging.CroppedBitmap();   break;
                case KnownElements.CultureInfoConverter: o = new System.ComponentModel.CultureInfoConverter();   break; 
                case KnownElements.CultureInfoIetfLanguageTagConverter: o = new System.Windows.CultureInfoIetfLanguageTagConverter();   break;
                case KnownElements.CursorConverter: o = new System.Windows.Input.CursorConverter();   break; 
                case KnownElements.DashStyle: o = new System.Windows.Media.DashStyle();   break; 
                case KnownElements.DataTemplate: o = new System.Windows.DataTemplate();   break;
                case KnownElements.DataTemplateKey: o = new System.Windows.DataTemplateKey();   break; 
                case KnownElements.DataTrigger: o = new System.Windows.DataTrigger();   break;
                case KnownElements.DateTimeConverter: o = new System.ComponentModel.DateTimeConverter();   break;
                case KnownElements.DateTimeConverter2: o = new System.Windows.Markup.DateTimeConverter2();   break;
                case KnownElements.DecimalAnimation: o = new System.Windows.Media.Animation.DecimalAnimation();   break; 
                case KnownElements.DecimalAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.DecimalAnimationUsingKeyFrames();   break;
                case KnownElements.DecimalConverter: o = new System.ComponentModel.DecimalConverter();   break; 
                case KnownElements.DecimalKeyFrameCollection: o = new System.Windows.Media.Animation.DecimalKeyFrameCollection();   break; 
                case KnownElements.Decorator: o = new System.Windows.Controls.Decorator();   break;
                case KnownElements.DependencyObject: o = new System.Windows.DependencyObject();   break; 
                case KnownElements.DependencyPropertyConverter: o = new System.Windows.Markup.DependencyPropertyConverter();   break;
                case KnownElements.DialogResultConverter: o = new System.Windows.DialogResultConverter();   break;
                case KnownElements.DiffuseMaterial: o = new System.Windows.Media.Media3D.DiffuseMaterial();   break;
                case KnownElements.DirectionalLight: o = new System.Windows.Media.Media3D.DirectionalLight();   break; 
                case KnownElements.DiscreteBooleanKeyFrame: o = new System.Windows.Media.Animation.DiscreteBooleanKeyFrame();   break;
                case KnownElements.DiscreteByteKeyFrame: o = new System.Windows.Media.Animation.DiscreteByteKeyFrame();   break; 
                case KnownElements.DiscreteCharKeyFrame: o = new System.Windows.Media.Animation.DiscreteCharKeyFrame();   break; 
                case KnownElements.DiscreteColorKeyFrame: o = new System.Windows.Media.Animation.DiscreteColorKeyFrame();   break;
                case KnownElements.DiscreteDecimalKeyFrame: o = new System.Windows.Media.Animation.DiscreteDecimalKeyFrame();   break; 
                case KnownElements.DiscreteDoubleKeyFrame: o = new System.Windows.Media.Animation.DiscreteDoubleKeyFrame();   break;
                case KnownElements.DiscreteInt16KeyFrame: o = new System.Windows.Media.Animation.DiscreteInt16KeyFrame();   break;
                case KnownElements.DiscreteInt32KeyFrame: o = new System.Windows.Media.Animation.DiscreteInt32KeyFrame();   break;
                case KnownElements.DiscreteInt64KeyFrame: o = new System.Windows.Media.Animation.DiscreteInt64KeyFrame();   break; 
                case KnownElements.DiscreteMatrixKeyFrame: o = new System.Windows.Media.Animation.DiscreteMatrixKeyFrame();   break;
                case KnownElements.DiscreteObjectKeyFrame: o = new System.Windows.Media.Animation.DiscreteObjectKeyFrame();   break; 
                case KnownElements.DiscretePoint3DKeyFrame: o = new System.Windows.Media.Animation.DiscretePoint3DKeyFrame();   break; 
                case KnownElements.DiscretePointKeyFrame: o = new System.Windows.Media.Animation.DiscretePointKeyFrame();   break;
                case KnownElements.DiscreteQuaternionKeyFrame: o = new System.Windows.Media.Animation.DiscreteQuaternionKeyFrame();   break; 
                case KnownElements.DiscreteRectKeyFrame: o = new System.Windows.Media.Animation.DiscreteRectKeyFrame();   break;
                case KnownElements.DiscreteRotation3DKeyFrame: o = new System.Windows.Media.Animation.DiscreteRotation3DKeyFrame();   break;
                case KnownElements.DiscreteSingleKeyFrame: o = new System.Windows.Media.Animation.DiscreteSingleKeyFrame();   break;
                case KnownElements.DiscreteSizeKeyFrame: o = new System.Windows.Media.Animation.DiscreteSizeKeyFrame();   break; 
                case KnownElements.DiscreteStringKeyFrame: o = new System.Windows.Media.Animation.DiscreteStringKeyFrame();   break;
                case KnownElements.DiscreteThicknessKeyFrame: o = new System.Windows.Media.Animation.DiscreteThicknessKeyFrame();   break; 
                case KnownElements.DiscreteVector3DKeyFrame: o = new System.Windows.Media.Animation.DiscreteVector3DKeyFrame();   break; 
                case KnownElements.DiscreteVectorKeyFrame: o = new System.Windows.Media.Animation.DiscreteVectorKeyFrame();   break;
                case KnownElements.DockPanel: o = new System.Windows.Controls.DockPanel();   break; 
                case KnownElements.DocumentPageView: o = new System.Windows.Controls.Primitives.DocumentPageView();   break;
                case KnownElements.DocumentReference: o = new System.Windows.Documents.DocumentReference();   break;
                case KnownElements.DocumentViewer: o = new System.Windows.Controls.DocumentViewer();   break;
                case KnownElements.DoubleAnimation: o = new System.Windows.Media.Animation.DoubleAnimation();   break; 
                case KnownElements.DoubleAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.DoubleAnimationUsingKeyFrames();   break;
                case KnownElements.DoubleAnimationUsingPath: o = new System.Windows.Media.Animation.DoubleAnimationUsingPath();   break; 
                case KnownElements.DoubleCollection: o = new System.Windows.Media.DoubleCollection();   break; 
                case KnownElements.DoubleCollectionConverter: o = new System.Windows.Media.DoubleCollectionConverter();   break;
                case KnownElements.DoubleConverter: o = new System.ComponentModel.DoubleConverter();   break; 
                case KnownElements.DoubleIListConverter: o = new System.Windows.Media.Converters.DoubleIListConverter();   break;
                case KnownElements.DoubleKeyFrameCollection: o = new System.Windows.Media.Animation.DoubleKeyFrameCollection();   break;
                case KnownElements.DrawingBrush: o = new System.Windows.Media.DrawingBrush();   break;
                case KnownElements.DrawingCollection: o = new System.Windows.Media.DrawingCollection();   break; 
                case KnownElements.DrawingGroup: o = new System.Windows.Media.DrawingGroup();   break;
                case KnownElements.DrawingImage: o = new System.Windows.Media.DrawingImage();   break; 
                case KnownElements.DrawingVisual: o = new System.Windows.Media.DrawingVisual();   break; 
                case KnownElements.DropShadowBitmapEffect: o = new System.Windows.Media.Effects.DropShadowBitmapEffect();   break;
                case KnownElements.Duration: o = new System.Windows.Duration();   break; 
                case KnownElements.DurationConverter: o = new System.Windows.DurationConverter();   break;
                case KnownElements.DynamicResourceExtension: o = new System.Windows.DynamicResourceExtension();   break;
                case KnownElements.DynamicResourceExtensionConverter: o = new System.Windows.DynamicResourceExtensionConverter();   break;
                case KnownElements.Ellipse: o = new System.Windows.Shapes.Ellipse();   break; 
                case KnownElements.EllipseGeometry: o = new System.Windows.Media.EllipseGeometry();   break;
                case KnownElements.EmbossBitmapEffect: o = new System.Windows.Media.Effects.EmbossBitmapEffect();   break; 
                case KnownElements.EmissiveMaterial: o = new System.Windows.Media.Media3D.EmissiveMaterial();   break; 
                case KnownElements.EventSetter: o = new System.Windows.EventSetter();   break;
                case KnownElements.EventTrigger: o = new System.Windows.EventTrigger();   break; 
                case KnownElements.Expander: o = new System.Windows.Controls.Expander();   break;
                case KnownElements.ExpressionConverter: o = new System.Windows.ExpressionConverter();   break;
                case KnownElements.Figure: o = new System.Windows.Documents.Figure();   break;
                case KnownElements.FigureLength: o = new System.Windows.FigureLength();   break; 
                case KnownElements.FigureLengthConverter: o = new System.Windows.FigureLengthConverter();   break;
                case KnownElements.FixedDocument: o = new System.Windows.Documents.FixedDocument();   break; 
                case KnownElements.FixedDocumentSequence: o = new System.Windows.Documents.FixedDocumentSequence();   break; 
                case KnownElements.FixedPage: o = new System.Windows.Documents.FixedPage();   break;
                case KnownElements.Floater: o = new System.Windows.Documents.Floater();   break; 
                case KnownElements.FlowDocument: o = new System.Windows.Documents.FlowDocument();   break;
                case KnownElements.FlowDocumentPageViewer: o = new System.Windows.Controls.FlowDocumentPageViewer();   break;
                case KnownElements.FlowDocumentReader: o = new System.Windows.Controls.FlowDocumentReader();   break;
                case KnownElements.FlowDocumentScrollViewer: o = new System.Windows.Controls.FlowDocumentScrollViewer();   break; 
                case KnownElements.FontFamily: o = new System.Windows.Media.FontFamily();   break;
                case KnownElements.FontFamilyConverter: o = new System.Windows.Media.FontFamilyConverter();   break; 
                case KnownElements.FontSizeConverter: o = new System.Windows.FontSizeConverter();   break; 
                case KnownElements.FontStretch: o = new System.Windows.FontStretch();   break;
                case KnownElements.FontStretchConverter: o = new System.Windows.FontStretchConverter();   break; 
                case KnownElements.FontStyle: o = new System.Windows.FontStyle();   break;
                case KnownElements.FontStyleConverter: o = new System.Windows.FontStyleConverter();   break;
                case KnownElements.FontWeight: o = new System.Windows.FontWeight();   break;
                case KnownElements.FontWeightConverter: o = new System.Windows.FontWeightConverter();   break; 
                case KnownElements.FormatConvertedBitmap: o = new System.Windows.Media.Imaging.FormatConvertedBitmap();   break;
                case KnownElements.Frame: o = new System.Windows.Controls.Frame();   break; 
                case KnownElements.FrameworkContentElement: o = new System.Windows.FrameworkContentElement();   break; 
                case KnownElements.FrameworkElement: o = new System.Windows.FrameworkElement();   break;
                case KnownElements.FrameworkElementFactory: o = new System.Windows.FrameworkElementFactory();   break; 
                case KnownElements.FrameworkPropertyMetadata: o = new System.Windows.FrameworkPropertyMetadata();   break;
                case KnownElements.GeneralTransformCollection: o = new System.Windows.Media.GeneralTransformCollection();   break;
                case KnownElements.GeneralTransformGroup: o = new System.Windows.Media.GeneralTransformGroup();   break;
                case KnownElements.GeometryCollection: o = new System.Windows.Media.GeometryCollection();   break; 
                case KnownElements.GeometryConverter: o = new System.Windows.Media.GeometryConverter();   break;
                case KnownElements.GeometryDrawing: o = new System.Windows.Media.GeometryDrawing();   break; 
                case KnownElements.GeometryGroup: o = new System.Windows.Media.GeometryGroup();   break; 
                case KnownElements.GeometryModel3D: o = new System.Windows.Media.Media3D.GeometryModel3D();   break;
                case KnownElements.GestureRecognizer: o = new System.Windows.Ink.GestureRecognizer();   break; 
                case KnownElements.GifBitmapEncoder: o = new System.Windows.Media.Imaging.GifBitmapEncoder();   break;
                case KnownElements.GlyphRun: o = new System.Windows.Media.GlyphRun();   break;
                case KnownElements.GlyphRunDrawing: o = new System.Windows.Media.GlyphRunDrawing();   break;
                case KnownElements.GlyphTypeface: o = new System.Windows.Media.GlyphTypeface();   break; 
                case KnownElements.Glyphs: o = new System.Windows.Documents.Glyphs();   break;
                case KnownElements.GradientStop: o = new System.Windows.Media.GradientStop();   break; 
                case KnownElements.GradientStopCollection: o = new System.Windows.Media.GradientStopCollection();   break; 
                case KnownElements.Grid: o = new System.Windows.Controls.Grid();   break;
                case KnownElements.GridLength: o = new System.Windows.GridLength();   break; 
                case KnownElements.GridLengthConverter: o = new System.Windows.GridLengthConverter();   break;
                case KnownElements.GridSplitter: o = new System.Windows.Controls.GridSplitter();   break;
                case KnownElements.GridView: o = new System.Windows.Controls.GridView();   break;
                case KnownElements.GridViewColumn: o = new System.Windows.Controls.GridViewColumn();   break; 
                case KnownElements.GridViewColumnHeader: o = new System.Windows.Controls.GridViewColumnHeader();   break;
                case KnownElements.GridViewHeaderRowPresenter: o = new System.Windows.Controls.GridViewHeaderRowPresenter();   break; 
                case KnownElements.GridViewRowPresenter: o = new System.Windows.Controls.GridViewRowPresenter();   break; 
                case KnownElements.GroupBox: o = new System.Windows.Controls.GroupBox();   break;
                case KnownElements.GroupItem: o = new System.Windows.Controls.GroupItem();   break; 
                case KnownElements.GuidConverter: o = new System.ComponentModel.GuidConverter();   break;
                case KnownElements.GuidelineSet: o = new System.Windows.Media.GuidelineSet();   break;
                case KnownElements.HeaderedContentControl: o = new System.Windows.Controls.HeaderedContentControl();   break;
                case KnownElements.HeaderedItemsControl: o = new System.Windows.Controls.HeaderedItemsControl();   break; 
                case KnownElements.HierarchicalDataTemplate: o = new System.Windows.HierarchicalDataTemplate();   break;
                case KnownElements.HostVisual: o = new System.Windows.Media.HostVisual();   break; 
                case KnownElements.Hyperlink: o = new System.Windows.Documents.Hyperlink();   break; 
                case KnownElements.Image: o = new System.Windows.Controls.Image();   break;
                case KnownElements.ImageBrush: o = new System.Windows.Media.ImageBrush();   break; 
                case KnownElements.ImageDrawing: o = new System.Windows.Media.ImageDrawing();   break;
                case KnownElements.ImageSourceConverter: o = new System.Windows.Media.ImageSourceConverter();   break;
                case KnownElements.InkCanvas: o = new System.Windows.Controls.InkCanvas();   break;
                case KnownElements.InkPresenter: o = new System.Windows.Controls.InkPresenter();   break; 
                case KnownElements.InlineUIContainer: o = new System.Windows.Documents.InlineUIContainer();   break;
                case KnownElements.InputScope: o = new System.Windows.Input.InputScope();   break; 
                case KnownElements.InputScopeConverter: o = new System.Windows.Input.InputScopeConverter();   break; 
                case KnownElements.InputScopeName: o = new System.Windows.Input.InputScopeName();   break;
                case KnownElements.InputScopeNameConverter: o = new System.Windows.Input.InputScopeNameConverter();   break; 
                case KnownElements.Int16Animation: o = new System.Windows.Media.Animation.Int16Animation();   break;
                case KnownElements.Int16AnimationUsingKeyFrames: o = new System.Windows.Media.Animation.Int16AnimationUsingKeyFrames();   break;
                case KnownElements.Int16Converter: o = new System.ComponentModel.Int16Converter();   break;
                case KnownElements.Int16KeyFrameCollection: o = new System.Windows.Media.Animation.Int16KeyFrameCollection();   break; 
                case KnownElements.Int32Animation: o = new System.Windows.Media.Animation.Int32Animation();   break;
                case KnownElements.Int32AnimationUsingKeyFrames: o = new System.Windows.Media.Animation.Int32AnimationUsingKeyFrames();   break; 
                case KnownElements.Int32Collection: o = new System.Windows.Media.Int32Collection();   break; 
                case KnownElements.Int32CollectionConverter: o = new System.Windows.Media.Int32CollectionConverter();   break;
                case KnownElements.Int32Converter: o = new System.ComponentModel.Int32Converter();   break; 
                case KnownElements.Int32KeyFrameCollection: o = new System.Windows.Media.Animation.Int32KeyFrameCollection();   break;
                case KnownElements.Int32Rect: o = new System.Windows.Int32Rect();   break;
                case KnownElements.Int32RectConverter: o = new System.Windows.Int32RectConverter();   break;
                case KnownElements.Int64Animation: o = new System.Windows.Media.Animation.Int64Animation();   break; 
                case KnownElements.Int64AnimationUsingKeyFrames: o = new System.Windows.Media.Animation.Int64AnimationUsingKeyFrames();   break;
                case KnownElements.Int64Converter: o = new System.ComponentModel.Int64Converter();   break; 
                case KnownElements.Int64KeyFrameCollection: o = new System.Windows.Media.Animation.Int64KeyFrameCollection();   break; 
                case KnownElements.Italic: o = new System.Windows.Documents.Italic();   break;
                case KnownElements.ItemsControl: o = new System.Windows.Controls.ItemsControl();   break; 
                case KnownElements.ItemsPanelTemplate: o = new System.Windows.Controls.ItemsPanelTemplate();   break;
                case KnownElements.ItemsPresenter: o = new System.Windows.Controls.ItemsPresenter();   break;
                case KnownElements.JournalEntryListConverter: o = new System.Windows.Navigation.JournalEntryListConverter();   break;
                case KnownElements.JournalEntryUnifiedViewConverter: o = new System.Windows.Navigation.JournalEntryUnifiedViewConverter();   break; 
                case KnownElements.JpegBitmapEncoder: o = new System.Windows.Media.Imaging.JpegBitmapEncoder();   break;
                case KnownElements.KeyBinding: o = new System.Windows.Input.KeyBinding();   break; 
                case KnownElements.KeyConverter: o = new System.Windows.Input.KeyConverter();   break; 
                case KnownElements.KeyGestureConverter: o = new System.Windows.Input.KeyGestureConverter();   break;
                case KnownElements.KeySpline: o = new System.Windows.Media.Animation.KeySpline();   break; 
                case KnownElements.KeySplineConverter: o = new System.Windows.KeySplineConverter();   break;
                case KnownElements.KeyTime: o = new System.Windows.Media.Animation.KeyTime();   break;
                case KnownElements.KeyTimeConverter: o = new System.Windows.KeyTimeConverter();   break;
                case KnownElements.Label: o = new System.Windows.Controls.Label();   break; 
                case KnownElements.LengthConverter: o = new System.Windows.LengthConverter();   break;
                case KnownElements.Line: o = new System.Windows.Shapes.Line();   break; 
                case KnownElements.LineBreak: o = new System.Windows.Documents.LineBreak();   break; 
                case KnownElements.LineGeometry: o = new System.Windows.Media.LineGeometry();   break;
                case KnownElements.LineSegment: o = new System.Windows.Media.LineSegment();   break; 
                case KnownElements.LinearByteKeyFrame: o = new System.Windows.Media.Animation.LinearByteKeyFrame();   break;
                case KnownElements.LinearColorKeyFrame: o = new System.Windows.Media.Animation.LinearColorKeyFrame();   break;
                case KnownElements.LinearDecimalKeyFrame: o = new System.Windows.Media.Animation.LinearDecimalKeyFrame();   break;
                case KnownElements.LinearDoubleKeyFrame: o = new System.Windows.Media.Animation.LinearDoubleKeyFrame();   break; 
                case KnownElements.LinearGradientBrush: o = new System.Windows.Media.LinearGradientBrush();   break;
                case KnownElements.LinearInt16KeyFrame: o = new System.Windows.Media.Animation.LinearInt16KeyFrame();   break; 
                case KnownElements.LinearInt32KeyFrame: o = new System.Windows.Media.Animation.LinearInt32KeyFrame();   break; 
                case KnownElements.LinearInt64KeyFrame: o = new System.Windows.Media.Animation.LinearInt64KeyFrame();   break;
                case KnownElements.LinearPoint3DKeyFrame: o = new System.Windows.Media.Animation.LinearPoint3DKeyFrame();   break; 
                case KnownElements.LinearPointKeyFrame: o = new System.Windows.Media.Animation.LinearPointKeyFrame();   break;
                case KnownElements.LinearQuaternionKeyFrame: o = new System.Windows.Media.Animation.LinearQuaternionKeyFrame();   break;
                case KnownElements.LinearRectKeyFrame: o = new System.Windows.Media.Animation.LinearRectKeyFrame();   break;
                case KnownElements.LinearRotation3DKeyFrame: o = new System.Windows.Media.Animation.LinearRotation3DKeyFrame();   break; 
                case KnownElements.LinearSingleKeyFrame: o = new System.Windows.Media.Animation.LinearSingleKeyFrame();   break;
                case KnownElements.LinearSizeKeyFrame: o = new System.Windows.Media.Animation.LinearSizeKeyFrame();   break; 
                case KnownElements.LinearThicknessKeyFrame: o = new System.Windows.Media.Animation.LinearThicknessKeyFrame();   break; 
                case KnownElements.LinearVector3DKeyFrame: o = new System.Windows.Media.Animation.LinearVector3DKeyFrame();   break;
                case KnownElements.LinearVectorKeyFrame: o = new System.Windows.Media.Animation.LinearVectorKeyFrame();   break; 
                case KnownElements.List: o = new System.Windows.Documents.List();   break;
                case KnownElements.ListBox: o = new System.Windows.Controls.ListBox();   break;
                case KnownElements.ListBoxItem: o = new System.Windows.Controls.ListBoxItem();   break;
                case KnownElements.ListItem: o = new System.Windows.Documents.ListItem();   break; 
                case KnownElements.ListView: o = new System.Windows.Controls.ListView();   break;
                case KnownElements.ListViewItem: o = new System.Windows.Controls.ListViewItem();   break; 
                case KnownElements.MaterialCollection: o = new System.Windows.Media.Media3D.MaterialCollection();   break; 
                case KnownElements.MaterialGroup: o = new System.Windows.Media.Media3D.MaterialGroup();   break;
                case KnownElements.Matrix: o = new System.Windows.Media.Matrix();   break; 
                case KnownElements.Matrix3D: o = new System.Windows.Media.Media3D.Matrix3D();   break;
                case KnownElements.Matrix3DConverter: o = new System.Windows.Media.Media3D.Matrix3DConverter();   break;
                case KnownElements.MatrixAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.MatrixAnimationUsingKeyFrames();   break;
                case KnownElements.MatrixAnimationUsingPath: o = new System.Windows.Media.Animation.MatrixAnimationUsingPath();   break; 
                case KnownElements.MatrixCamera: o = new System.Windows.Media.Media3D.MatrixCamera();   break;
                case KnownElements.MatrixConverter: o = new System.Windows.Media.MatrixConverter();   break; 
                case KnownElements.MatrixKeyFrameCollection: o = new System.Windows.Media.Animation.MatrixKeyFrameCollection();   break; 
                case KnownElements.MatrixTransform: o = new System.Windows.Media.MatrixTransform();   break;
                case KnownElements.MatrixTransform3D: o = new System.Windows.Media.Media3D.MatrixTransform3D();   break; 
                case KnownElements.MediaElement: o = new System.Windows.Controls.MediaElement();   break;
                case KnownElements.MediaPlayer: o = new System.Windows.Media.MediaPlayer();   break;
                case KnownElements.MediaTimeline: o = new System.Windows.Media.MediaTimeline();   break;
                case KnownElements.Menu: o = new System.Windows.Controls.Menu();   break; 
                case KnownElements.MenuItem: o = new System.Windows.Controls.MenuItem();   break;
                case KnownElements.MenuScrollingVisibilityConverter: o = new System.Windows.Controls.MenuScrollingVisibilityConverter();   break; 
                case KnownElements.MeshGeometry3D: o = new System.Windows.Media.Media3D.MeshGeometry3D();   break; 
                case KnownElements.Model3DCollection: o = new System.Windows.Media.Media3D.Model3DCollection();   break;
                case KnownElements.Model3DGroup: o = new System.Windows.Media.Media3D.Model3DGroup();   break; 
                case KnownElements.ModelVisual3D: o = new System.Windows.Media.Media3D.ModelVisual3D();   break;
                case KnownElements.ModifierKeysConverter: o = new System.Windows.Input.ModifierKeysConverter();   break;
                case KnownElements.MouseActionConverter: o = new System.Windows.Input.MouseActionConverter();   break;
                case KnownElements.MouseBinding: o = new System.Windows.Input.MouseBinding();   break; 
                case KnownElements.MouseGesture: o = new System.Windows.Input.MouseGesture();   break;
                case KnownElements.MouseGestureConverter: o = new System.Windows.Input.MouseGestureConverter();   break; 
                case KnownElements.MultiBinding: o = new System.Windows.Data.MultiBinding();   break; 
                case KnownElements.MultiDataTrigger: o = new System.Windows.MultiDataTrigger();   break;
                case KnownElements.MultiTrigger: o = new System.Windows.MultiTrigger();   break; 
                case KnownElements.NameScope: o = new System.Windows.NameScope();   break;
                case KnownElements.NavigationWindow: o = new System.Windows.Navigation.NavigationWindow();   break;
                case KnownElements.NullExtension: o = new System.Windows.Markup.NullExtension();   break;
                case KnownElements.NullableBoolConverter: o = new System.Windows.NullableBoolConverter();   break; 
                case KnownElements.NumberSubstitution: o = new System.Windows.Media.NumberSubstitution();   break;
                case KnownElements.Object: o = new System.Object();   break; 
                case KnownElements.ObjectAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.ObjectAnimationUsingKeyFrames();   break; 
                case KnownElements.ObjectDataProvider: o = new System.Windows.Data.ObjectDataProvider();   break;
                case KnownElements.ObjectKeyFrameCollection: o = new System.Windows.Media.Animation.ObjectKeyFrameCollection();   break; 
                case KnownElements.OrthographicCamera: o = new System.Windows.Media.Media3D.OrthographicCamera();   break;
                case KnownElements.OuterGlowBitmapEffect: o = new System.Windows.Media.Effects.OuterGlowBitmapEffect();   break;
                case KnownElements.Page: o = new System.Windows.Controls.Page();   break;
                case KnownElements.PageContent: o = new System.Windows.Documents.PageContent();   break; 
                case KnownElements.Paragraph: o = new System.Windows.Documents.Paragraph();   break;
                case KnownElements.ParallelTimeline: o = new System.Windows.Media.Animation.ParallelTimeline();   break; 
                case KnownElements.ParserContext: o = new System.Windows.Markup.ParserContext();   break; 
                case KnownElements.PasswordBox: o = new System.Windows.Controls.PasswordBox();   break;
                case KnownElements.Path: o = new System.Windows.Shapes.Path();   break; 
                case KnownElements.PathFigure: o = new System.Windows.Media.PathFigure();   break;
                case KnownElements.PathFigureCollection: o = new System.Windows.Media.PathFigureCollection();   break;
                case KnownElements.PathFigureCollectionConverter: o = new System.Windows.Media.PathFigureCollectionConverter();   break;
                case KnownElements.PathGeometry: o = new System.Windows.Media.PathGeometry();   break; 
                case KnownElements.PathSegmentCollection: o = new System.Windows.Media.PathSegmentCollection();   break;
                case KnownElements.PauseStoryboard: o = new System.Windows.Media.Animation.PauseStoryboard();   break; 
                case KnownElements.Pen: o = new System.Windows.Media.Pen();   break; 
                case KnownElements.PerspectiveCamera: o = new System.Windows.Media.Media3D.PerspectiveCamera();   break;
                case KnownElements.PixelFormat: o = new System.Windows.Media.PixelFormat();   break; 
                case KnownElements.PixelFormatConverter: o = new System.Windows.Media.PixelFormatConverter();   break;
                case KnownElements.PngBitmapEncoder: o = new System.Windows.Media.Imaging.PngBitmapEncoder();   break;
                case KnownElements.Point: o = new System.Windows.Point();   break;
                case KnownElements.Point3D: o = new System.Windows.Media.Media3D.Point3D();   break; 
                case KnownElements.Point3DAnimation: o = new System.Windows.Media.Animation.Point3DAnimation();   break;
                case KnownElements.Point3DAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.Point3DAnimationUsingKeyFrames();   break; 
                case KnownElements.Point3DCollection: o = new System.Windows.Media.Media3D.Point3DCollection();   break; 
                case KnownElements.Point3DCollectionConverter: o = new System.Windows.Media.Media3D.Point3DCollectionConverter();   break;
                case KnownElements.Point3DConverter: o = new System.Windows.Media.Media3D.Point3DConverter();   break; 
                case KnownElements.Point3DKeyFrameCollection: o = new System.Windows.Media.Animation.Point3DKeyFrameCollection();   break;
                case KnownElements.Point4D: o = new System.Windows.Media.Media3D.Point4D();   break;
                case KnownElements.Point4DConverter: o = new System.Windows.Media.Media3D.Point4DConverter();   break;
                case KnownElements.PointAnimation: o = new System.Windows.Media.Animation.PointAnimation();   break; 
                case KnownElements.PointAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.PointAnimationUsingKeyFrames();   break;
                case KnownElements.PointAnimationUsingPath: o = new System.Windows.Media.Animation.PointAnimationUsingPath();   break; 
                case KnownElements.PointCollection: o = new System.Windows.Media.PointCollection();   break; 
                case KnownElements.PointCollectionConverter: o = new System.Windows.Media.PointCollectionConverter();   break;
                case KnownElements.PointConverter: o = new System.Windows.PointConverter();   break; 
                case KnownElements.PointIListConverter: o = new System.Windows.Media.Converters.PointIListConverter();   break;
                case KnownElements.PointKeyFrameCollection: o = new System.Windows.Media.Animation.PointKeyFrameCollection();   break;
                case KnownElements.PointLight: o = new System.Windows.Media.Media3D.PointLight();   break;
                case KnownElements.PolyBezierSegment: o = new System.Windows.Media.PolyBezierSegment();   break; 
                case KnownElements.PolyLineSegment: o = new System.Windows.Media.PolyLineSegment();   break;
                case KnownElements.PolyQuadraticBezierSegment: o = new System.Windows.Media.PolyQuadraticBezierSegment();   break; 
                case KnownElements.Polygon: o = new System.Windows.Shapes.Polygon();   break; 
                case KnownElements.Polyline: o = new System.Windows.Shapes.Polyline();   break;
                case KnownElements.Popup: o = new System.Windows.Controls.Primitives.Popup();   break; 
                case KnownElements.PriorityBinding: o = new System.Windows.Data.PriorityBinding();   break;
                case KnownElements.ProgressBar: o = new System.Windows.Controls.ProgressBar();   break;
                case KnownElements.PropertyPathConverter: o = new System.Windows.PropertyPathConverter();   break;
                case KnownElements.QuadraticBezierSegment: o = new System.Windows.Media.QuadraticBezierSegment();   break; 
                case KnownElements.Quaternion: o = new System.Windows.Media.Media3D.Quaternion();   break;
                case KnownElements.QuaternionAnimation: o = new System.Windows.Media.Animation.QuaternionAnimation();   break; 
                case KnownElements.QuaternionAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.QuaternionAnimationUsingKeyFrames();   break; 
                case KnownElements.QuaternionConverter: o = new System.Windows.Media.Media3D.QuaternionConverter();   break;
                case KnownElements.QuaternionKeyFrameCollection: o = new System.Windows.Media.Animation.QuaternionKeyFrameCollection();   break; 
                case KnownElements.QuaternionRotation3D: o = new System.Windows.Media.Media3D.QuaternionRotation3D();   break;
                case KnownElements.RadialGradientBrush: o = new System.Windows.Media.RadialGradientBrush();   break;
                case KnownElements.RadioButton: o = new System.Windows.Controls.RadioButton();   break;
                case KnownElements.Rect: o = new System.Windows.Rect();   break; 
                case KnownElements.Rect3D: o = new System.Windows.Media.Media3D.Rect3D();   break;
                case KnownElements.Rect3DConverter: o = new System.Windows.Media.Media3D.Rect3DConverter();   break; 
                case KnownElements.RectAnimation: o = new System.Windows.Media.Animation.RectAnimation();   break; 
                case KnownElements.RectAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.RectAnimationUsingKeyFrames();   break;
                case KnownElements.RectConverter: o = new System.Windows.RectConverter();   break; 
                case KnownElements.RectKeyFrameCollection: o = new System.Windows.Media.Animation.RectKeyFrameCollection();   break;
                case KnownElements.Rectangle: o = new System.Windows.Shapes.Rectangle();   break;
                case KnownElements.RectangleGeometry: o = new System.Windows.Media.RectangleGeometry();   break;
                case KnownElements.RelativeSource: o = new System.Windows.Data.RelativeSource();   break; 
                case KnownElements.RemoveStoryboard: o = new System.Windows.Media.Animation.RemoveStoryboard();   break;
                case KnownElements.RepeatBehavior: o = new System.Windows.Media.Animation.RepeatBehavior();   break; 
                case KnownElements.RepeatBehaviorConverter: o = new System.Windows.Media.Animation.RepeatBehaviorConverter();   break; 
                case KnownElements.RepeatButton: o = new System.Windows.Controls.Primitives.RepeatButton();   break;
                case KnownElements.ResizeGrip: o = new System.Windows.Controls.Primitives.ResizeGrip();   break; 
                case KnownElements.ResourceDictionary: o = new System.Windows.ResourceDictionary();   break;
                case KnownElements.ResumeStoryboard: o = new System.Windows.Media.Animation.ResumeStoryboard();   break;
                case KnownElements.RichTextBox: o = new System.Windows.Controls.RichTextBox();   break;
                case KnownElements.RotateTransform: o = new System.Windows.Media.RotateTransform();   break; 
                case KnownElements.RotateTransform3D: o = new System.Windows.Media.Media3D.RotateTransform3D();   break;
                case KnownElements.Rotation3DAnimation: o = new System.Windows.Media.Animation.Rotation3DAnimation();   break; 
                case KnownElements.Rotation3DAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.Rotation3DAnimationUsingKeyFrames();   break; 
                case KnownElements.Rotation3DKeyFrameCollection: o = new System.Windows.Media.Animation.Rotation3DKeyFrameCollection();   break;
                case KnownElements.RoutedCommand: o = new System.Windows.Input.RoutedCommand();   break; 
                case KnownElements.RoutedEventConverter: o = new System.Windows.Markup.RoutedEventConverter();   break;
                case KnownElements.RoutedUICommand: o = new System.Windows.Input.RoutedUICommand();   break;
                case KnownElements.RowDefinition: o = new System.Windows.Controls.RowDefinition();   break;
                case KnownElements.Run: o = new System.Windows.Documents.Run();   break; 
                case KnownElements.SByteConverter: o = new System.ComponentModel.SByteConverter();   break;
                case KnownElements.ScaleTransform: o = new System.Windows.Media.ScaleTransform();   break; 
                case KnownElements.ScaleTransform3D: o = new System.Windows.Media.Media3D.ScaleTransform3D();   break; 
                case KnownElements.ScrollBar: o = new System.Windows.Controls.Primitives.ScrollBar();   break;
                case KnownElements.ScrollContentPresenter: o = new System.Windows.Controls.ScrollContentPresenter();   break; 
                case KnownElements.ScrollViewer: o = new System.Windows.Controls.ScrollViewer();   break;
                case KnownElements.Section: o = new System.Windows.Documents.Section();   break;
                case KnownElements.SeekStoryboard: o = new System.Windows.Media.Animation.SeekStoryboard();   break;
                case KnownElements.Separator: o = new System.Windows.Controls.Separator();   break; 
                case KnownElements.SetStoryboardSpeedRatio: o = new System.Windows.Media.Animation.SetStoryboardSpeedRatio();   break;
                case KnownElements.Setter: o = new System.Windows.Setter();   break; 
                case KnownElements.SingleAnimation: o = new System.Windows.Media.Animation.SingleAnimation();   break; 
                case KnownElements.SingleAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.SingleAnimationUsingKeyFrames();   break;
                case KnownElements.SingleConverter: o = new System.ComponentModel.SingleConverter();   break; 
                case KnownElements.SingleKeyFrameCollection: o = new System.Windows.Media.Animation.SingleKeyFrameCollection();   break;
                case KnownElements.Size: o = new System.Windows.Size();   break;
                case KnownElements.Size3D: o = new System.Windows.Media.Media3D.Size3D();   break;
                case KnownElements.Size3DConverter: o = new System.Windows.Media.Media3D.Size3DConverter();   break; 
                case KnownElements.SizeAnimation: o = new System.Windows.Media.Animation.SizeAnimation();   break;
                case KnownElements.SizeAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.SizeAnimationUsingKeyFrames();   break; 
                case KnownElements.SizeConverter: o = new System.Windows.SizeConverter();   break; 
                case KnownElements.SizeKeyFrameCollection: o = new System.Windows.Media.Animation.SizeKeyFrameCollection();   break;
                case KnownElements.SkewTransform: o = new System.Windows.Media.SkewTransform();   break; 
                case KnownElements.SkipStoryboardToFill: o = new System.Windows.Media.Animation.SkipStoryboardToFill();   break;
                case KnownElements.Slider: o = new System.Windows.Controls.Slider();   break;
                case KnownElements.SolidColorBrush: o = new System.Windows.Media.SolidColorBrush();   break;
                case KnownElements.SoundPlayerAction: o = new System.Windows.Controls.SoundPlayerAction();   break; 
                case KnownElements.Span: o = new System.Windows.Documents.Span();   break;
                case KnownElements.SpecularMaterial: o = new System.Windows.Media.Media3D.SpecularMaterial();   break; 
                case KnownElements.SplineByteKeyFrame: o = new System.Windows.Media.Animation.SplineByteKeyFrame();   break; 
                case KnownElements.SplineColorKeyFrame: o = new System.Windows.Media.Animation.SplineColorKeyFrame();   break;
                case KnownElements.SplineDecimalKeyFrame: o = new System.Windows.Media.Animation.SplineDecimalKeyFrame();   break; 
                case KnownElements.SplineDoubleKeyFrame: o = new System.Windows.Media.Animation.SplineDoubleKeyFrame();   break;
                case KnownElements.SplineInt16KeyFrame: o = new System.Windows.Media.Animation.SplineInt16KeyFrame();   break;
                case KnownElements.SplineInt32KeyFrame: o = new System.Windows.Media.Animation.SplineInt32KeyFrame();   break;
                case KnownElements.SplineInt64KeyFrame: o = new System.Windows.Media.Animation.SplineInt64KeyFrame();   break; 
                case KnownElements.SplinePoint3DKeyFrame: o = new System.Windows.Media.Animation.SplinePoint3DKeyFrame();   break;
                case KnownElements.SplinePointKeyFrame: o = new System.Windows.Media.Animation.SplinePointKeyFrame();   break; 
                case KnownElements.SplineQuaternionKeyFrame: o = new System.Windows.Media.Animation.SplineQuaternionKeyFrame();   break; 
                case KnownElements.SplineRectKeyFrame: o = new System.Windows.Media.Animation.SplineRectKeyFrame();   break;
                case KnownElements.SplineRotation3DKeyFrame: o = new System.Windows.Media.Animation.SplineRotation3DKeyFrame();   break; 
                case KnownElements.SplineSingleKeyFrame: o = new System.Windows.Media.Animation.SplineSingleKeyFrame();   break;
                case KnownElements.SplineSizeKeyFrame: o = new System.Windows.Media.Animation.SplineSizeKeyFrame();   break;
                case KnownElements.SplineThicknessKeyFrame: o = new System.Windows.Media.Animation.SplineThicknessKeyFrame();   break;
                case KnownElements.SplineVector3DKeyFrame: o = new System.Windows.Media.Animation.SplineVector3DKeyFrame();   break; 
                case KnownElements.SplineVectorKeyFrame: o = new System.Windows.Media.Animation.SplineVectorKeyFrame();   break;
                case KnownElements.SpotLight: o = new System.Windows.Media.Media3D.SpotLight();   break; 
                case KnownElements.StackPanel: o = new System.Windows.Controls.StackPanel();   break; 
                case KnownElements.StaticExtension: o = new System.Windows.Markup.StaticExtension();   break;
                case KnownElements.StaticResourceExtension: o = new System.Windows.StaticResourceExtension();   break; 
                case KnownElements.StatusBar: o = new System.Windows.Controls.Primitives.StatusBar();   break;
                case KnownElements.StatusBarItem: o = new System.Windows.Controls.Primitives.StatusBarItem();   break;
                case KnownElements.StopStoryboard: o = new System.Windows.Media.Animation.StopStoryboard();   break;
                case KnownElements.Storyboard: o = new System.Windows.Media.Animation.Storyboard();   break; 
                case KnownElements.StreamGeometry: o = new System.Windows.Media.StreamGeometry();   break;
                case KnownElements.StreamResourceInfo: o = new System.Windows.Resources.StreamResourceInfo();   break; 
                case KnownElements.StringAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.StringAnimationUsingKeyFrames();   break; 
                case KnownElements.StringConverter: o = new System.ComponentModel.StringConverter();   break;
                case KnownElements.StringKeyFrameCollection: o = new System.Windows.Media.Animation.StringKeyFrameCollection();   break; 
                case KnownElements.StrokeCollection: o = new System.Windows.Ink.StrokeCollection();   break;
                case KnownElements.StrokeCollectionConverter: o = new System.Windows.StrokeCollectionConverter();   break;
                case KnownElements.Style: o = new System.Windows.Style();   break;
                case KnownElements.TabControl: o = new System.Windows.Controls.TabControl();   break; 
                case KnownElements.TabItem: o = new System.Windows.Controls.TabItem();   break;
                case KnownElements.TabPanel: o = new System.Windows.Controls.Primitives.TabPanel();   break; 
                case KnownElements.Table: o = new System.Windows.Documents.Table();   break; 
                case KnownElements.TableCell: o = new System.Windows.Documents.TableCell();   break;
                case KnownElements.TableColumn: o = new System.Windows.Documents.TableColumn();   break; 
                case KnownElements.TableRow: o = new System.Windows.Documents.TableRow();   break;
                case KnownElements.TableRowGroup: o = new System.Windows.Documents.TableRowGroup();   break;
                case KnownElements.TemplateBindingExpressionConverter: o = new System.Windows.TemplateBindingExpressionConverter();   break;
                case KnownElements.TemplateBindingExtension: o = new System.Windows.TemplateBindingExtension();   break; 
                case KnownElements.TemplateBindingExtensionConverter: o = new System.Windows.TemplateBindingExtensionConverter();   break;
                case KnownElements.TemplateKeyConverter: o = new System.Windows.Markup.TemplateKeyConverter();   break; 
                case KnownElements.TextBlock: o = new System.Windows.Controls.TextBlock();   break; 
                case KnownElements.TextBox: o = new System.Windows.Controls.TextBox();   break;
                case KnownElements.TextDecoration: o = new System.Windows.TextDecoration();   break; 
                case KnownElements.TextDecorationCollection: o = new System.Windows.TextDecorationCollection();   break;
                case KnownElements.TextDecorationCollectionConverter: o = new System.Windows.TextDecorationCollectionConverter();   break;
                case KnownElements.TextEffect: o = new System.Windows.Media.TextEffect();   break;
                case KnownElements.TextEffectCollection: o = new System.Windows.Media.TextEffectCollection();   break; 
                case KnownElements.ThemeDictionaryExtension: o = new System.Windows.ThemeDictionaryExtension();   break;
                case KnownElements.Thickness: o = new System.Windows.Thickness();   break; 
                case KnownElements.ThicknessAnimation: o = new System.Windows.Media.Animation.ThicknessAnimation();   break; 
                case KnownElements.ThicknessAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.ThicknessAnimationUsingKeyFrames();   break;
                case KnownElements.ThicknessConverter: o = new System.Windows.ThicknessConverter();   break; 
                case KnownElements.ThicknessKeyFrameCollection: o = new System.Windows.Media.Animation.ThicknessKeyFrameCollection();   break;
                case KnownElements.Thumb: o = new System.Windows.Controls.Primitives.Thumb();   break;
                case KnownElements.TickBar: o = new System.Windows.Controls.Primitives.TickBar();   break;
                case KnownElements.TiffBitmapEncoder: o = new System.Windows.Media.Imaging.TiffBitmapEncoder();   break; 
                case KnownElements.TimeSpanConverter: o = new System.ComponentModel.TimeSpanConverter();   break;
                case KnownElements.TimelineCollection: o = new System.Windows.Media.Animation.TimelineCollection();   break; 
                case KnownElements.ToggleButton: o = new System.Windows.Controls.Primitives.ToggleButton();   break; 
                case KnownElements.ToolBar: o = new System.Windows.Controls.ToolBar();   break;
                case KnownElements.ToolBarOverflowPanel: o = new System.Windows.Controls.Primitives.ToolBarOverflowPanel();   break; 
                case KnownElements.ToolBarPanel: o = new System.Windows.Controls.Primitives.ToolBarPanel();   break;
                case KnownElements.ToolBarTray: o = new System.Windows.Controls.ToolBarTray();   break;
                case KnownElements.ToolTip: o = new System.Windows.Controls.ToolTip();   break;
                case KnownElements.Track: o = new System.Windows.Controls.Primitives.Track();   break; 
                case KnownElements.Transform3DCollection: o = new System.Windows.Media.Media3D.Transform3DCollection();   break;
                case KnownElements.Transform3DGroup: o = new System.Windows.Media.Media3D.Transform3DGroup();   break; 
                case KnownElements.TransformCollection: o = new System.Windows.Media.TransformCollection();   break; 
                case KnownElements.TransformConverter: o = new System.Windows.Media.TransformConverter();   break;
                case KnownElements.TransformGroup: o = new System.Windows.Media.TransformGroup();   break; 
                case KnownElements.TransformedBitmap: o = new System.Windows.Media.Imaging.TransformedBitmap();   break;
                case KnownElements.TranslateTransform: o = new System.Windows.Media.TranslateTransform();   break;
                case KnownElements.TranslateTransform3D: o = new System.Windows.Media.Media3D.TranslateTransform3D();   break;
                case KnownElements.TreeView: o = new System.Windows.Controls.TreeView();   break; 
                case KnownElements.TreeViewItem: o = new System.Windows.Controls.TreeViewItem();   break;
                case KnownElements.Trigger: o = new System.Windows.Trigger();   break; 
                case KnownElements.TypeExtension: o = new System.Windows.Markup.TypeExtension();   break; 
                case KnownElements.TypeTypeConverter: o = new System.Windows.Markup.TypeTypeConverter();   break;
                case KnownElements.UIElement: o = new System.Windows.UIElement();   break; 
                case KnownElements.UInt16Converter: o = new System.ComponentModel.UInt16Converter();   break;
                case KnownElements.UInt32Converter: o = new System.ComponentModel.UInt32Converter();   break;
                case KnownElements.UInt64Converter: o = new System.ComponentModel.UInt64Converter();   break;
                case KnownElements.UShortIListConverter: o = new System.Windows.Media.Converters.UShortIListConverter();   break; 
                case KnownElements.Underline: o = new System.Windows.Documents.Underline();   break;
                case KnownElements.UniformGrid: o = new System.Windows.Controls.Primitives.UniformGrid();   break; 
                case KnownElements.UriTypeConverter: o = new System.UriTypeConverter();   break; 
                case KnownElements.UserControl: o = new System.Windows.Controls.UserControl();   break;
                case KnownElements.Vector: o = new System.Windows.Vector();   break; 
                case KnownElements.Vector3D: o = new System.Windows.Media.Media3D.Vector3D();   break;
                case KnownElements.Vector3DAnimation: o = new System.Windows.Media.Animation.Vector3DAnimation();   break;
                case KnownElements.Vector3DAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.Vector3DAnimationUsingKeyFrames();   break;
                case KnownElements.Vector3DCollection: o = new System.Windows.Media.Media3D.Vector3DCollection();   break; 
                case KnownElements.Vector3DCollectionConverter: o = new System.Windows.Media.Media3D.Vector3DCollectionConverter();   break;
                case KnownElements.Vector3DConverter: o = new System.Windows.Media.Media3D.Vector3DConverter();   break; 
                case KnownElements.Vector3DKeyFrameCollection: o = new System.Windows.Media.Animation.Vector3DKeyFrameCollection();   break; 
                case KnownElements.VectorAnimation: o = new System.Windows.Media.Animation.VectorAnimation();   break;
                case KnownElements.VectorAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.VectorAnimationUsingKeyFrames();   break; 
                case KnownElements.VectorCollection: o = new System.Windows.Media.VectorCollection();   break;
                case KnownElements.VectorCollectionConverter: o = new System.Windows.Media.VectorCollectionConverter();   break;
                case KnownElements.VectorConverter: o = new System.Windows.VectorConverter();   break;
                case KnownElements.VectorKeyFrameCollection: o = new System.Windows.Media.Animation.VectorKeyFrameCollection();   break; 
                case KnownElements.VideoDrawing: o = new System.Windows.Media.VideoDrawing();   break;
                case KnownElements.Viewbox: o = new System.Windows.Controls.Viewbox();   break; 
                case KnownElements.Viewport3D: o = new System.Windows.Controls.Viewport3D();   break; 
                case KnownElements.Viewport3DVisual: o = new System.Windows.Media.Media3D.Viewport3DVisual();   break;
                case KnownElements.VirtualizingStackPanel: o = new System.Windows.Controls.VirtualizingStackPanel();   break; 
                case KnownElements.VisualBrush: o = new System.Windows.Media.VisualBrush();   break;
                case KnownElements.Window: o = new System.Windows.Window();   break;
                case KnownElements.WmpBitmapEncoder: o = new System.Windows.Media.Imaging.WmpBitmapEncoder();   break;
                case KnownElements.WrapPanel: o = new System.Windows.Controls.WrapPanel();   break; 
                case KnownElements.XamlBrushSerializer: o = new System.Windows.Markup.XamlBrushSerializer();   break;
                case KnownElements.XamlInt32CollectionSerializer: o = new System.Windows.Markup.XamlInt32CollectionSerializer();   break; 
                case KnownElements.XamlPathDataSerializer: o = new System.Windows.Markup.XamlPathDataSerializer();   break; 
                case KnownElements.XamlPoint3DCollectionSerializer: o = new System.Windows.Markup.XamlPoint3DCollectionSerializer();   break;
                case KnownElements.XamlPointCollectionSerializer: o = new System.Windows.Markup.XamlPointCollectionSerializer();   break; 
                case KnownElements.XamlStyleSerializer: o = new System.Windows.Markup.XamlStyleSerializer();   break;
                case KnownElements.XamlTemplateSerializer: o = new System.Windows.Markup.XamlTemplateSerializer();   break;
                case KnownElements.XamlVector3DCollectionSerializer: o = new System.Windows.Markup.XamlVector3DCollectionSerializer();   break;
                case KnownElements.XmlDataProvider: o = new System.Windows.Data.XmlDataProvider();   break; 
                case KnownElements.XmlLanguageConverter: o = new System.Windows.Markup.XmlLanguageConverter();   break;
                case KnownElements.XmlNamespaceMapping: o = new System.Windows.Data.XmlNamespaceMapping();   break; 
                case KnownElements.ZoomPercentageConverter: o = new System.Windows.Documents.ZoomPercentageConverter();   break; 
            }
            return o; 
        }
Esempio n. 2
0
        protected Guid GetUuid(string localId, string uuidString)
        {
            if (String.IsNullOrEmpty(localId))
            {
                return Guid.Empty;
            }

               CorrelatedResSyncInfo[] results =  _correlatedResSyncInfoStore.GetByLocalId(_resourceKindString, new string[]{localId});
               if (results.Length > 0)
               return results[0].ResSyncInfo.Uuid;
            Guid result;
            if (string.IsNullOrEmpty(uuidString))
                   result = Guid.NewGuid();
            else
                try
                {
                    GuidConverter converter = new GuidConverter();
                    result = (Guid)converter.ConvertFromString(uuidString);
                    if (Guid.Empty.Equals(result))
                        result = Guid.NewGuid();
                }
                catch (Exception)
                {
                    result = Guid.NewGuid();
                }

                ResSyncInfo newResSyncInfo = new ResSyncInfo(result, _originApplication, 0, string.Empty, DateTime.Now);
                CorrelatedResSyncInfo newCorrelation = new CorrelatedResSyncInfo(localId, newResSyncInfo);
                _correlatedResSyncInfoStore.Put(_resourceKindString, newCorrelation);
               return result;
        }
Esempio n. 3
0
 protected string GetLocalId(string uuidString)
 {
     GuidConverter converter = new GuidConverter();
     try
     {
         Guid uuid = (Guid)converter.ConvertFromString(uuidString);
         return GetLocalId(uuid);
     }
     catch (Exception)
     {
         return string.Empty;
     }
 }
        public void DoWork(IRequest request)
        {
            // If an asyncState object already exists, an exception is thrown as the performer only accepts
            // one call after each other. The Request receiver has to manage a queued execution.

            // Before calling the performers execution implementation method a new AsyncState object is created
            // and set to an initial tracking state.

            lock (_asyncStateObj)
            {
                if (null != _asyncStateObj.Tracking)
                    throw new InvalidOperationException("The performer cannot be executed because it is already running.");

                SyncTracking tracking = new SyncTracking();
                tracking.ElapsedSeconds = 1;
                tracking.Phase = TrackingPhase.INIT;
                tracking.PhaseDetail = "Tracking Id was: " + _requestContext.TrackingId.ToString();
                tracking.PollingMillis = 100;
                tracking.RemainingSeconds = 100;

                _asyncStateObj.Tracking = tracking;
            }

            // *** Initialization for the async execution ***
            // - Read Feed from request stream.
            // - Read trackingId from request URL

            // convert tracking ID from request to type Guid
            string strTrackingId = request.Uri.TrackingID;
            if (String.IsNullOrEmpty(strTrackingId))
                throw new RequestException("TrackingId is missing");

            GuidConverter converter = new GuidConverter();
            this.TrackingId = (Guid)converter.ConvertFrom(strTrackingId);

            //read feed
            SyncFeed feed = new SyncFeed();
            XmlReader reader = XmlReader.Create(request.Stream);
            feed.ReadXml(reader, ResourceKindHelpers.GetPayloadType(_requestContext.ResourceKind));

            // *** Do work asynchronously ***
            _asyncPerformer = new InternalAsyncPerformer(this);
            _asyncPerformer.DoWork(_requestContext.Config, feed);

            // *** set the tracking to the request response ***
            this.GetTrackingState(request);
        }
        private Guid StringToGuid(string guid)
        {
            try
            {
                GuidConverter converter = new GuidConverter();

                Guid result = (Guid)converter.ConvertFromString(guid);
                return result;
            }
            catch
            {
                return Guid.Empty;
            }
        }
 private string GetLocalId(string uuidString, SupportedResourceKinds resKind)
 {
     GuidConverter converter = new GuidConverter();
     try
     {
         Guid uuid = (Guid)converter.ConvertFromString(uuidString);
         return GetLocalId(uuid, resKind);
     }
     catch (Exception)
     {
         return string.Empty;
     }
 }
Esempio n. 7
0
        public RequestContext(SDataUri sdataUri)
        {
            this.SdataUri = sdataUri;

            // config
            NorthwindConfig newConfig = new NorthwindConfig(sdataUri.CompanyDataset);

            newConfig.CurrencyCode = "EUR";
            newConfig.CrmUser = "******";
            newConfig.Path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Northwind");

            this.Config = newConfig;

            // initialize requestType
            this.RequestType = RequestType.None;

            // hasTrackingId
            this.HasTrackingId = false;

            // baseLink
            string newBaseLink = string.Empty;

            if (String.IsNullOrEmpty(sdataUri.Scheme))
                newBaseLink += "http://";
            else
                newBaseLink += sdataUri.Scheme + "://";

            if (String.IsNullOrEmpty(sdataUri.Host))
                newBaseLink += "localhost";
            else
                newBaseLink += sdataUri.Host;

            if (sdataUri.Port > 0)
                newBaseLink += ":" + sdataUri.Port.ToString();

            if (String.IsNullOrEmpty(sdataUri.Server))
                newBaseLink += "/sdata/";
            else
                newBaseLink += "/" + sdataUri.Server + "/";

            this.BaseLink = newBaseLink;

            // application
            this.Application = (sdataUri.PathSegments.Length > 0) ? sdataUri.PathSegments[0].Text : "";

            // applicationLink
            this.ApplicationLink = this.BaseLink + this.Application + "/";

            if (sdataUri.PathSegments.Length == 1)
            {
                this.RequestType = RequestType.Contract;            // -> Type: contract
                return;
            }

            // contract
            string newContract = sdataUri.PathSegments[1].Text;

            if (newContract == "*")
            {
                this.RequestType = RequestType.Contract;            // -> Type: contract
                this.Contract = string.Empty;
                return;
            }
            this.Contract = newContract;

            // contractLink
            this.ContractLink = this.ApplicationLink + this.Contract + "/";

            if (sdataUri.PathSegments.Length == 2)
            {
                this.RequestType = RequestType.Dataset;             // -> Type: dataset
                return;
            }

            // dataset
            string newDataset = sdataUri.PathSegments[2].Text;

            if (newDataset == "*")
            {
                this.RequestType = RequestType.Dataset;             // -> Type: dataset
                this.Dataset = string.Empty;
                return;
            }
            this.Dataset = newDataset;

            // datasetLink
            this.DatasetLink = this.ContractLink + this.Dataset + "/";

            // sdataContext
            this.SdataContext = new SdataContext(this.Application, this.Dataset, this.Contract, this.DatasetLink);

            if (this.SdataUri.PathSegments.Length == 3)
            {
                if (!string.IsNullOrEmpty(this.SdataUri.ServiceMethod))
                {
                    this.RequestType = RequestType.Service;                    // -> Type: Service
                    return;
                }

                this.RequestType = RequestType.ResourceCollection;  // -> Type: ResourceCollection
                return;
            }

            string temp;
            temp = this.SdataUri.PathSegments[3].Text;

            if (temp == "*")
            {
                this.RequestType = RequestType.ResourceCollection;      // -> Type: ResourceCollection
                return;
            }

            if (temp.Equals(Constants.schema, StringComparison.InvariantCultureIgnoreCase))
            {
                // check whether it is an import schema
                if (this.SdataUri.PathSegments.Length == 4)
                {
                    this.RequestType = RequestType.ResourceCollectionSchema;    // -> Type: ResourceCollectionSchema
                    return;
                }
                else if (this.SdataUri.PathSegments.Length == 6 && this.SdataUri.PathSegments[4].Text.Equals("import", StringComparison.InvariantCultureIgnoreCase) && (!string.IsNullOrEmpty(this.SdataUri.PathSegments[5].Text)))
                {
                    this.ImportSchemaName = this.SdataUri.PathSegments[5].Text;
                    this.RequestType = RequestType.ImportSchema;    // -> Type: ImportSchema
                    return;
                }

            }
            if (temp.Equals(Constants.service, StringComparison.InvariantCultureIgnoreCase))
            {
                if (this.SdataUri.PathSegments.Length >= 6)
                {
                    this.SdataUri.ServiceMethod = this.SdataUri.PathSegments[4].Text;
                    if (this.SdataUri.PathSegments[5].Text.Equals(Constants.schema, StringComparison.InvariantCultureIgnoreCase))
                    {
                        this.RequestType = RequestType.ServiceSchema;

                        return;
                    }
                }
                else
                {
                    throw new RequestException(string.Format("Url {0} cannot be parsed.", this.SdataUri.ToString()));
                }
            }

            try
            {
                // resourceKind
                this.ResourceKind = (SupportedResourceKinds)Enum.Parse(typeof(SupportedResourceKinds), temp, true);

                if (sdataUri.PathSegments.Length > 4 && sdataUri.PathSegments[4].Text.Equals(Constants.linked, StringComparison.InvariantCultureIgnoreCase))
                {
                    this.RequestType = RequestType.Linked;                    // -> Type: Linked

                    // resourceKey
                    if (sdataUri.PathSegments[4].HasPredicate)
                    {
                        if (sdataUri.PathSegments[4].PredicateExpression is StringLiteralExpression)
                        {
                            this.ResourceKey = ((StringLiteralExpression)sdataUri.PathSegments[4].PredicateExpression).Value.ToString();
                            return;
                        }
                        else
                        {
                            this.RequestType = RequestType.None;            // -> Type: None
                            this.ResourceKind = SupportedResourceKinds.None;
                            this.ErrorMessage = "please specify the primary Key inside the predicate as string";
                            return;
                        }
                    }
                }
                else if (!string.IsNullOrEmpty(this.SdataUri.ServiceMethod))
                {

                    if (sdataUri.PathSegments.Length >= 7 && sdataUri.PathSegments[6].Text.Equals(Constants.schema, StringComparison.InvariantCultureIgnoreCase))
                        this.RequestType = RequestType.ServiceSchema;   // currently we do not enter here, but we don't know if SIF will be changed to set the service name
                    else
                        this.RequestType = RequestType.Service;                    // -> Type: Service
                    return;
                }
                else if (sdataUri.PathSegments.Length >= 7 &&
                    sdataUri.PathSegments[4].Text.Equals(Constants.service, StringComparison.InvariantCultureIgnoreCase) &&
                    sdataUri.PathSegments[6].Text.Equals(Constants.schema, StringComparison.InvariantCultureIgnoreCase))
                {
                    this.SdataUri.ServiceMethod = sdataUri.PathSegments[5].Text;
                    this.RequestType = RequestType.ServiceSchema;
                    return;
                }
                else
                {
                    this.RequestType = RequestType.Resource;                    // -> Type. Resource

                    // resourceKey
                    if (sdataUri.PathSegments[3].HasPredicate)
                    {
                        if (sdataUri.PathSegments[3].PredicateExpression is StringLiteralExpression)
                        {
                            this.ResourceKey = ((StringLiteralExpression)sdataUri.PathSegments[3].PredicateExpression).Value.ToString();
                            return;
                        }
                        else
                        {
                            this.RequestType = RequestType.None;            // -> Type: None
                            this.ResourceKind = SupportedResourceKinds.None;
                            this.ErrorMessage = "please specify the primary Key inside the predicate as string";
                            return;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                this.RequestType = RequestType.None;
                this.ResourceKind = SupportedResourceKinds.None;
                this.ErrorMessage = e.Message;
                return;
            }

            if (this.SdataUri.PathSegments.Length == 4)
                return;

            temp = sdataUri.PathSegments[4].Text;

            if (temp.Equals(Constants.schema, StringComparison.InvariantCultureIgnoreCase))
            {
                this.RequestType = RequestType.ResourceSchema;      // -> Type: ResourceSchema
                return;
            }

            if (temp.Equals(Constants.template, StringComparison.InvariantCultureIgnoreCase))
            {
                this.RequestType = RequestType.Template;        // -> Type: template
                return;
            }

            if (temp.Equals(Constants.syncDigest, StringComparison.InvariantCultureIgnoreCase))
            {
                this.RequestType = RequestType.SyncDigest;          // -> Type: syncDigest
                return;
            }

            if (temp.Equals(Constants.syncResults, StringComparison.InvariantCultureIgnoreCase))
            {
                this.RequestType = RequestType.SyncResults;      // -> Type: SyncResults
                return;
            }

            if ((temp.Equals(Constants.syncSource, StringComparison.InvariantCultureIgnoreCase))
                || (temp.Equals(Constants.syncTarget, StringComparison.InvariantCultureIgnoreCase)))
            {
                if (temp.Equals(Constants.syncSource, StringComparison.InvariantCultureIgnoreCase))
                    this.RequestType = RequestType.SyncSource;              // -> Type: syncSource
                if (temp.Equals(Constants.syncTarget, StringComparison.InvariantCultureIgnoreCase))
                    this.RequestType = RequestType.SyncTarget;              // -> Type: syncTarget

                if (!string.IsNullOrEmpty(sdataUri.TrackingID))
                {
                    try
                    {
                        GuidConverter converter = new GuidConverter();

                        this.TrackingId = (Guid)converter.ConvertFrom(sdataUri.TrackingID);
                        this.HasTrackingId = true;
                    }
                    catch (Exception)
                    {
                    }
                }
                else if (this.SdataUri.PathSegments[4].HasPredicate)
                {
                    try
                    {
                        GuidConverter converter = new GuidConverter();
                        this.TrackingId = (Guid)converter.ConvertFrom(((StringLiteralExpression)this.SdataUri.PathSegments[4].PredicateExpression).Value);
                        this.HasTrackingId = true;
                    }
                    catch (Exception)
                    {
                    }
                }
                return;
            }
        }
        private void txtSusID_TextChanged(object sender, EventArgs e)
        {
            // If we have a valid GUID, enable the Add button
            GuidConverter c = new GuidConverter();

            btnAdd.Enabled = c.IsValid(txtSusID.Text);
        }
 private string GetTradingAccountLocalId(string uuidString)
 {
     GuidConverter converter = new GuidConverter();
     try
     {
         Guid uuid = (Guid)converter.ConvertFromString(uuidString);
         return GetTradingAccountLocalId(uuid);
     }
     catch (Exception)
     {
         return "";
     }
 }
Esempio n. 10
0
        private static TypeConverter GetCoreConverterFromCoreType(Type type)
        {
            TypeConverter typeConverter = null;

            if (type == typeof(Int32))
            {
                typeConverter = new System.ComponentModel.Int32Converter();
            }
            else if (type == typeof(Int16))
            {
                typeConverter = new System.ComponentModel.Int16Converter();
            }
            else if (type == typeof(Int64))
            {
                typeConverter = new System.ComponentModel.Int64Converter();
            }
            else if (type == typeof(UInt32))
            {
                typeConverter = new System.ComponentModel.UInt32Converter();
            }
            else if (type == typeof(UInt16))
            {
                typeConverter = new System.ComponentModel.UInt16Converter();
            }
            else if (type == typeof(UInt64))
            {
                typeConverter = new System.ComponentModel.UInt64Converter();
            }
            else if (type == typeof(Boolean))
            {
                typeConverter = new System.ComponentModel.BooleanConverter();
            }
            else if (type == typeof(Double))
            {
                typeConverter = new System.ComponentModel.DoubleConverter();
            }
            else if (type == typeof(Single))
            {
                typeConverter = new System.ComponentModel.SingleConverter();
            }
            else if (type == typeof(Byte))
            {
                typeConverter = new System.ComponentModel.ByteConverter();
            }
            else if (type == typeof(SByte))
            {
                typeConverter = new System.ComponentModel.SByteConverter();
            }
            else if (type == typeof(Char))
            {
                typeConverter = new System.ComponentModel.CharConverter();
            }
            else if (type == typeof(Decimal))
            {
                typeConverter = new System.ComponentModel.DecimalConverter();
            }
            else if (type == typeof(TimeSpan))
            {
                typeConverter = new System.ComponentModel.TimeSpanConverter();
            }
            else if (type == typeof(Guid))
            {
                typeConverter = new System.ComponentModel.GuidConverter();
            }
            else if (type == typeof(String))
            {
                typeConverter = new System.ComponentModel.StringConverter();
            }
            else if (type == typeof(CultureInfo))
            {
                typeConverter = new System.ComponentModel.CultureInfoConverter();
            }
#if !SYSTEM_XAML
            else if (type == typeof(Type))
            {
                typeConverter = new System.Windows.Markup.TypeTypeConverter();
            }
#else
            else if (type == typeof(Type))
            {
                typeConverter = new System.Xaml.Replacements.TypeTypeConverter();
            }
#endif
            else if (type == typeof(DateTime))
            {
                typeConverter = new DateTimeConverter2();
            }
            else if (ReflectionHelper.IsNullableType(type))
            {
                typeConverter = new System.ComponentModel.NullableConverter(type);
            }

            return(typeConverter);
        }
        public void DoWork(IRequest request)
        {
            // If an asyncState object already exists, an exception is thrown as the performer only accepts
            // one call after each other. The Request receiver has to manage a queued execution.

            // Before calling the performers execution implementation method a new AsyncState object is created
            // and set to an initial tracking state.

            lock (_asyncStateObj)
            {
                if (null != _asyncStateObj.Tracking)
                    throw new InvalidOperationException("The performer cannot be executed because it is already running.");

                SyncTracking tracking = new SyncTracking();
                tracking.ElapsedSeconds = 1;
                tracking.Phase = TrackingPhase.INIT;
                tracking.PhaseDetail = "Tracking Id was: " + _requestContext.TrackingId.ToString();
                tracking.PollingMillis = 100;
                tracking.RemainingSeconds = 100;

                _asyncStateObj.Tracking = tracking;
            }

            // *** Initialization for the async execution ***
            // - Read SyncDigest from request stream.
            // - Read trackingId from request URL

            //// Load input stream (throws RequestException if it fails.)
            //XmlDocument xmlInputDoc;
            //InputStreamHelpers.Get(request, out xmlInputDoc);

            //// load syncDigest info from input stream of the request
            //SyncDigestInfo syncDigestInfo = SyncDigestInfoHelpers.Load(xmlInputDoc);

            SyncFeedEntry entry = new SyncFeedEntry();
            XmlReader reader = XmlReader.Create(request.Stream);
            reader.MoveToContent();
            entry.ReadXml(reader, typeof(SyncDigestPayload));
            if (entry.Payload == null)
            {
                throw new RequestException("Invalid Content");
            }
            SyncFeedDigest syncDigestInfo = ((SyncDigestPayload)entry.Payload).Digest;

            // convert tracking ID from request to type Guid
            string strTrackingId = request.Uri.TrackingID;
            if (String.IsNullOrEmpty(strTrackingId))
                throw new RequestException("TrackingId is missing");

            GuidConverter converter = new GuidConverter();
            this.TrackingId = (Guid)converter.ConvertFrom(strTrackingId);

            // *** Do work asynchronously ***
            _asyncPerformer = new InternalAsyncPerformer(this);
            _asyncPerformer.DoWork(_requestContext.Config, syncDigestInfo);

            // *** set the tracking to the request response ***
            this.GetTrackingState(request);
        }
Esempio n. 12
0
        public void ReadXml(System.Xml.XmlReader reader, Type payloadType)
        {
            GuidConverter guidConverter = new GuidConverter();
            if ((reader.NodeType == System.Xml.XmlNodeType.Element)
                && (reader.LocalName == "entry")
                && (reader.NamespaceURI == Namespaces.atomNamespace))
            {
                bool reading = true;
                while (reading)
                {
                    if (reader.NodeType == System.Xml.XmlNodeType.Element)
                    {
                        switch (reader.LocalName)
                        {
                            case "title":
                                reading = reader.Read();
                                if (reader.NodeType == System.Xml.XmlNodeType.Text)
                                    this.Title = reader.Value;
                                break;
                            case "id":
                                reading = reader.Read();
                                if (reader.NodeType == System.Xml.XmlNodeType.Text)
                                    this.Id = reader.Value;
                                break;

                            case "uuid":
                                reading = reader.Read();
                                if (reader.NodeType == System.Xml.XmlNodeType.Text)
                                {
                                    string uuidString = reader.Value;

                                    this.Uuid = (Guid)guidConverter.ConvertFromString(uuidString);
                                }
                                break;

                            case "httpStatus":
                                reading = reader.Read();
                                if (reader.NodeType == System.Xml.XmlNodeType.Text)
                                    this.HttpStatusCode = (HttpStatusCode)Enum.Parse(typeof(HttpStatusCode), reader.Value);
                                break;

                            case "httpMessage":
                                reading = reader.Read();
                                if (reader.NodeType == System.Xml.XmlNodeType.Text)
                                    this.HttpMessage = reader.Value;
                                break;

                            case "location":
                                reading = reader.Read();
                                if (reader.NodeType == System.Xml.XmlNodeType.Text)
                                    this.HttpLocation = reader.Value;
                                break;

                            case "httpMethod":
                                reading = reader.Read();
                                if (reader.NodeType == System.Xml.XmlNodeType.Text)
                                    this.HttpMethod = reader.Value;
                                break;

                            case "payload":
                                System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(payloadType);
                                object obj = serializer.Deserialize(reader);
                                if (obj is PayloadBase)
                                    this.Payload = obj as PayloadBase;
                                break;

                            case "syncState":
                                System.Xml.Serialization.XmlSerializer syncStateSerializer = new System.Xml.Serialization.XmlSerializer(typeof(SyncState));
                                object obj1 = syncStateSerializer.Deserialize(reader);
                                if (obj1 is SyncState)
                                    this.SyncState = obj1 as SyncState;
                                break;
                            case "link":

                                if (reader.HasAttributes)
                                {
                                    SyncFeedEntryLink link = new SyncFeedEntryLink();
                                    while (reader.MoveToNextAttribute())
                                    {
                                        if (reader.LocalName.Equals("payloadpath", StringComparison.InvariantCultureIgnoreCase))
                                            link.PayloadPath = reader.Value;
                                        if (reader.LocalName.Equals("rel", StringComparison.InvariantCultureIgnoreCase))
                                            link.LinkRel = reader.Value;
                                        if (reader.LocalName.Equals("type", StringComparison.InvariantCultureIgnoreCase))
                                            link.LinkType = reader.Value;
                                        if (reader.LocalName.Equals("title", StringComparison.InvariantCultureIgnoreCase))
                                            link.Title = reader.Value;
                                        if (reader.LocalName.Equals("uuid", StringComparison.InvariantCultureIgnoreCase))
                                            link.Uuid = reader.Value;
                                        if (reader.LocalName.Equals("href", StringComparison.InvariantCultureIgnoreCase))
                                            link.Href = reader.Value;
                                    }

                                    this.SyncLinks.Add(link);

                                }
                                break;
                            case "linked":
                                System.Xml.Serialization.XmlSerializer linkedSerializer = new System.Xml.Serialization.XmlSerializer(typeof(LinkedElement));
                                object linkedObj = linkedSerializer.Deserialize(reader);
                                if (linkedObj is LinkedElement)
                                    this.Linked = linkedObj as LinkedElement;
                                break;

                            default:
                                reading = reader.Read();
                                break;
                        }

                    }
                    else
                    {
                        if ((reader.NodeType == System.Xml.XmlNodeType.EndElement)
                            && (reader.LocalName == "entry"))
                            reading = false;
                        else
                            reading = reader.Read();
                    }
                }
            }
        }
Esempio n. 13
0
        internal static SdataTransactionResult GetSdataTransactionResult(List<TransactionResult> transactions, string endpoint, SupportedResourceKinds resource)
        {
            if (transactions == null)
                return null;
            if (transactions.Count == 0)
                return null;

            GuidConverter guidConverter = new GuidConverter();
            SdataTransactionResult result;
            foreach (TransactionResult transaction in transactions)
            {
                if (transaction.Status != TransactionStatus.Success)
                {
                    result = new SdataTransactionResult();
                    result.ResourceKind = resource;
                    result.LocalId = transaction.ID;
                    try
                    {
                        result.Uuid = (Guid)guidConverter.ConvertFromString(transaction.CRMID);
                    }
                    catch (Exception)
                    { }
                    result.HttpMessage = transaction.Message;
                    result.Location = endpoint + "('" + transaction.ID + "')";
                    result.HttpStatus = Helper.GetHttpStatus(transaction.Status, transaction.Action);
                    result.HttpMethod = Helper.GetHttpMethod(transaction.Action);
                    return result;
                }
            }
            if (transactions.Count == 0)
                return null;

            result = new SdataTransactionResult();
            result.ResourceKind = resource;
            result.LocalId = transactions[0].ID;
            try
            {
                result.Uuid = (Guid)guidConverter.ConvertFromString(transactions[0].CRMID);
            }
            catch (Exception)
            { }
            result.HttpMessage = transactions[0].Message;
            result.Location = endpoint + "('" + transactions[0].ID + "')";
            result.HttpStatus = Helper.GetHttpStatus(transactions[0].Status, transactions[0].Action);
            result.HttpMethod = Helper.GetHttpMethod(transactions[0].Action);
            return result;
        }
Esempio n. 14
0
        private void PersistRelations(List<TransactionResult> transactions)
        {
            GuidConverter guidConverter = new GuidConverter();
            foreach (TransactionResult transaction in transactions)
            {
                if (transaction.Status == TransactionStatus.Success)
                {
                    SupportedResourceKinds resourceKind = GetSupportedResourceKind(transaction.EntityName);
                    if (resourceKind == SupportedResourceKinds.None)
                        continue;

                    string uuidString = transaction.CRMID;
                    Guid uuid = Guid.Empty;
                    try
                    {
                        uuid = (Guid)guidConverter.ConvertFromString(uuidString);
                    }
                    catch
                    {
                        continue;
                    }
                    if (uuid == Guid.Empty)
                        continue;

                    string localId = transaction.ID;
                    ResSyncInfo resSyncInfo = new ResSyncInfo(uuid, _context.DatasetLink + resourceKind.ToString(), -1, "", DateTime.Now);

                    CorrelatedResSyncInfo correlatedResSyncInfo = new CorrelatedResSyncInfo(localId, resSyncInfo);

                    // store the new correlation to the sync store
                    _correlatedResSyncInfoStore.Put(resourceKind.ToString(), correlatedResSyncInfo);

                }
            }
        }
            // Asynchronous called method
            private void Execute(NorthwindConfig config, SyncFeed feed)
            {
                #region Declarations

                SdataContext sdataContext;
                SupportedResourceKinds resource;
                IAppBookmarkInfoStore appBookmarkInfoStore;
                ICorrelatedResSyncInfoStore correlatedResSyncInfoStore;
                ISyncSyncDigestInfoStore syncDigestStore;

                GuidConverter guidConverter = new GuidConverter();
                string resourceKind;
                string endpoint;
                SyncFeedDigest sourceDigest;
                SyncDigestInfo targetDigest;

                IEntityWrapper wrapper;

                #endregion

                #region init

                sdataContext = _parentPerformer._requestContext.SdataContext;
                resource = _parentPerformer._requestContext.ResourceKind;
                resourceKind = resource.ToString();
                endpoint = _parentPerformer._requestContext.DatasetLink + resourceKind;
                appBookmarkInfoStore = RequestReceiver.NorthwindAdapter.StoreLocator.GetAppBookmarkStore(sdataContext);
                correlatedResSyncInfoStore = RequestReceiver.NorthwindAdapter.StoreLocator.GetCorrelatedResSyncStore(sdataContext);
                syncDigestStore = RequestReceiver.NorthwindAdapter.StoreLocator.GetSyncDigestStore(sdataContext);
                sourceDigest = feed.Digest;
                targetDigest = syncDigestStore.Get(resourceKind);
                wrapper = EntityWrapperFactory.Create(resource, _parentPerformer._requestContext);

                #endregion

                #region process entries

                bool sourceIsDeleteMode;
                SdataTransactionResult sdTrResult;
                SyncState sourceState;
                SyncState targetState;

                foreach (SyncFeedEntry entry in feed.Entries)
                {
                    sdTrResult = null;

                    try
                    {
                        // Check whether the source entry had been deleted.
                        // if not we expect a payload!
                        // The variable 'sourceIsDeleteMode' holds the result of this check for later calls.
                        if (entry.HttpMethod.Equals("DELETE", StringComparison.InvariantCultureIgnoreCase))
                            sourceIsDeleteMode = true;
                        else if (null == entry.Payload)
                            throw new Exception("Payload missing.");
                        else
                            sourceIsDeleteMode = false;

                        // set the uuid to the payload.SyncUuid property
                        if (!sourceIsDeleteMode) { entry.Payload.SyncUuid = entry.Uuid; }

                        // get the source syncstate
                        sourceState = entry.SyncState;

                        // Look into the store to get all correlations of the uuid received from source
                        CorrelatedResSyncInfo[] corelations = correlatedResSyncInfoStore.GetByUuid(resourceKind, new Guid[] { entry.Uuid });

                        if (corelations.Length == 0)
                        {
                            if (sourceIsDeleteMode)
                            {
                                // the source entry had been deleted and no correlation exists for this
                                // entry in the target.
                                // So we do nothing here.
                                sdTrResult = new SdataTransactionResult();
                                sdTrResult.HttpStatus = HttpStatusCode.OK;
                                sdTrResult.HttpMessage = "OK";
                                sdTrResult.HttpMethod = "DELETE";
                                sdTrResult.ResourceKind = resource;
                                sdTrResult.Uuid = entry.Uuid;
                            }
                            else
                            {
                                // no target entry exists for the updated or added source entry.
                                // So we add the source entry to the application and add a new correlation to the sync store.
                                // If this operation fails we will have to set the result state to conflict.
                                try
                                {
                                    // add the entry to application
                                    sdTrResult = wrapper.Add(entry.Payload, entry.SyncLinks);

                                    if ((sdTrResult != null) && ((sdTrResult.HttpStatus == HttpStatusCode.OK) || (sdTrResult.HttpStatus == HttpStatusCode.Created)))
                                    {
                                        string etag = EtagServices.ComputeEtag(entry.Payload, true);

                                        ResSyncInfo resSyncInfo =
                                            new ResSyncInfo(entry.Uuid, entry.SyncState.Endpoint,
                                                entry.SyncState.Tick, etag, entry.SyncState.Stamp);

                                        CorrelatedResSyncInfo correlatedResSyncInfo = new CorrelatedResSyncInfo(sdTrResult.LocalId, resSyncInfo);

                                        // store the new correlation to the sync store
                                        correlatedResSyncInfoStore.Put(resourceKind, correlatedResSyncInfo);
                                        // update the sync digest entry if the tick of the source entry is newer than the actual tick of the target.
                                        syncDigestStore.PersistNewer(resourceKind, correlatedResSyncInfo.ResSyncInfo);
                                    }
                                }
                                catch (Exception e)
                                {
                                    // in case of an unexpected error while adding a new entry to target
                                    // we create a transaction result with the state 'Conflict'
                                    sdTrResult = new SdataTransactionResult();
                                    sdTrResult.HttpStatus = HttpStatusCode.Conflict;
                                    sdTrResult.HttpMethod = "POST";
                                    sdTrResult.HttpMessage = e.ToString();
                                    sdTrResult.ResourceKind = resource;
                                    sdTrResult.Uuid = entry.Uuid;
                                }
                            }
                        }
                        else
                        {
                            // a correlation was found for the source entry.

                            #region update or delete

                            try
                            {
                                bool doUpdate = false;
                                //bool doDelete = false;
                                bool isConflict = true;

                                // set the LocalID from correlation to the entry.Payload.LocalID property
                                // only if source had not been deleted.
                                if (!sourceIsDeleteMode) { entry.Payload.LocalID = corelations[0].LocalId; }

                                targetState = Helper.GetSyncState( corelations[0]);

                                //If sourceState.endpoint = targetState.endpoint,
                                //there is no conflict and the update must be applied
                                //if sourceState.tick > targetState.tick.
                                if (targetState.Endpoint.Equals(sourceState.Endpoint, StringComparison.InvariantCultureIgnoreCase))
                                {
                                    isConflict = false;
                                    if (sourceState.Tick > targetState.Tick)
                                    {
                                        //if (!sourceIsDeleteMode)
                                            doUpdate = true;
                                        //else
                                        //    doDelete = true;
                                    }
                                }
                                else
                                {
                                    SyncState sourceDigestSyncState = Helper.GetSyncState(sourceDigest, targetState.Endpoint); ;
                                    SyncState targetDigestSyncState = Helper.GetSyncState(targetDigest, sourceState.Endpoint);

                                    //If targetState is contained in sourceDigest,
                                    //i.e. if sourceDigest has a digest entry E such that E.endpoint = targetState.endpoint
                                    //and E.tick >= targetState.tick, there is no conflict and the update must be applied.
                                    if (sourceDigestSyncState != null)
                                    {
                                        if (sourceDigestSyncState.Tick > targetState.Tick)
                                        {
                                            doUpdate = true;
                                            isConflict = false;
                                        }
                                    }

                                    //If sourceState is contained in targetDigest,
                                    //i.e. if targetDigest has a digest entry E such that E.endpoint = sourceState.endpoint
                                    //and E.tick >= sourceState.tick, there is no conflict and the update must be ignored
                                    //(target has the most recent version).
                                    if (targetDigestSyncState != null)
                                    {
                                        if (targetDigestSyncState.Tick > sourceState.Tick)
                                        {
                                            doUpdate = false;
                                            isConflict = false;
                                        }
                                    }

                                    //Otherwise (targetState not contained in sourceDigest, sourceState not contained in targetDigest),
                                    //there is a conflict.
                                    if ((sourceDigestSyncState == null) && (targetDigestSyncState == null))
                                        isConflict = true;
                                }

                                //****************** Conflict ****************
                                //In case of conflict, the target endpoint uses the following algorithm to resolve the conflict:
                               //Let sourceEntry be the sourceDigest digest entry such that sourceEntry.endpoint = sourceState.endpoint.
                                //Let targetEntry be the targetDigest digest entry such that targetEntry.endpoint = targetState.endpoint.
                                //If sourceEntry .conflictPriority <> targetEntry .conflictPriority, the side with lowest priority wins.
                                if(isConflict)
                                {
                                    int sourceConflictPriority = Helper.GetConflictPriority(sourceDigest, sourceState.Endpoint);
                                    int targetConflictPriority = Helper.GetConflictPriority(targetDigest, targetState.Endpoint);

                                    if (sourceConflictPriority > targetConflictPriority)
                                    {
                                        doUpdate = true;
                                    }
                                    else if (sourceConflictPriority < targetConflictPriority)
                                    {
                                        doUpdate = false;
                                    }
                                    else
                                    {
                                        //Otherwise (sourceEntry .conflictPriority = targetEntry .conflictPriority),
                                        //then sourceState.stamp and targetState.stamp are compared
                                        //and the entry with the most recent timestamp wins.
                                        if (sourceState.Stamp > targetState.Stamp)
                                        {
                                            doUpdate = true;
                                        }
                                    }

                                }
                                ResSyncInfo resSyncInfo =
                                            new ResSyncInfo(entry.Uuid, entry.SyncState.Endpoint,
                                                entry.SyncState.Tick, "", entry.SyncState.Stamp);

                                if (doUpdate && !sourceIsDeleteMode)
                                {
                                    // update the entry in the application and update the sync store
                                    sdTrResult = wrapper.Update(entry.Payload, entry.SyncLinks);

                                    if ((sdTrResult != null) && (sdTrResult.HttpStatus == HttpStatusCode.OK))
                                    {
                                        string etag = EtagServices.ComputeEtag(entry.Payload, true);

                                        resSyncInfo =
                                            new ResSyncInfo(entry.Uuid, entry.SyncState.Endpoint,
                                                entry.SyncState.Tick, etag, entry.SyncState.Stamp);

                                        CorrelatedResSyncInfo correlatedResSyncInfo = new CorrelatedResSyncInfo(sdTrResult.LocalId, resSyncInfo);

                                        correlatedResSyncInfoStore.Put(resourceKind, correlatedResSyncInfo);
                                    }
                                }
                                else if (!doUpdate && !sourceIsDeleteMode)
                                {
                                    sdTrResult = new SdataTransactionResult();
                                    sdTrResult.HttpStatus = HttpStatusCode.Conflict;
                                    sdTrResult.HttpMethod = "PUT";
                                    sdTrResult.HttpMessage = "";
                                    sdTrResult.ResourceKind = resource;
                                    sdTrResult.Uuid = entry.Uuid;
                                }
                                else if (doUpdate && sourceIsDeleteMode)
                                {
                                    // delete the entry in the application and update the sync store
                                    // we do not support nested deletion. So only TradingAccounts and SalesOrders can be deleted.
                                    if (resource == SupportedResourceKinds.tradingAccounts
                                        || resource == SupportedResourceKinds.salesOrders)
                                    {
                                        sdTrResult = wrapper.Delete(corelations[0].LocalId);

                                        if ((sdTrResult != null) && (sdTrResult.HttpStatus == HttpStatusCode.OK))
                                        {
                                            correlatedResSyncInfoStore.Delete(resource.ToString(), corelations[0].ResSyncInfo.Uuid);
                                        }
                                    }
                                    else
                                    {
                                        // this  does not correspond to real fact, what we did at target side!
                                        sdTrResult = new SdataTransactionResult();
                                        sdTrResult.HttpStatus = HttpStatusCode.OK;
                                        sdTrResult.HttpMessage = "OK";
                                        sdTrResult.HttpMethod = "DELETE";
                                        sdTrResult.ResourceKind = resource;
                                        sdTrResult.Uuid = entry.Uuid;
                                    }
                                }
                                else
                                {
                                    sdTrResult = new SdataTransactionResult();
                                    sdTrResult.HttpStatus = HttpStatusCode.Conflict;
                                    sdTrResult.HttpMessage = "";
                                    sdTrResult.HttpMethod = "DELETE";
                                    sdTrResult.ResourceKind = resource;
                                    sdTrResult.Uuid = entry.Uuid;
                                }

                                syncDigestStore.PersistNewer(resourceKind, resSyncInfo);

                            }
                            catch (Exception e)
                            {
                                sdTrResult = new SdataTransactionResult();
                                sdTrResult.HttpStatus = HttpStatusCode.Conflict;
                                sdTrResult.HttpMethod = "PUT";
                                sdTrResult.HttpMessage = e.ToString();
                                sdTrResult.ResourceKind = resource;
                                sdTrResult.Uuid = entry.Uuid;
                            }
                            #endregion
                        }
                    }
                    catch (Exception e)
                    {
                        sdTrResult = new SdataTransactionResult();
                        sdTrResult.HttpStatus = HttpStatusCode.Conflict;
                        sdTrResult.HttpMessage = e.ToString();
                        sdTrResult.ResourceKind = resource;
                        sdTrResult.Uuid = entry.Uuid;
                    }

                    #region store transaction result

                    if (sdTrResult != null)
                    {
                        lock (_parentPerformer._asyncStateObj)
                        {
                            this._parentPerformer._asyncStateObj.TransactionResults.Add(sdTrResult);
                        }
                    }

                    #endregion

                }
                #endregion

                // Set tracking phase
                lock (_parentPerformer._asyncStateObj.Tracking)
                {
                    _parentPerformer._asyncStateObj.Tracking.Phase = TrackingPhase.FINISH;
                }
            }
Esempio n. 16
0
        private static TypeConverter GetCoreConverterFromCoreType(Type type)
        { 
            TypeConverter typeConverter = null; 
            if (type == typeof(Int32))
            { 
                typeConverter = new System.ComponentModel.Int32Converter();
            }
            else if (type == typeof(Int16))
            { 
                typeConverter = new System.ComponentModel.Int16Converter();
            } 
            else if (type == typeof(Int64)) 
            {
                typeConverter = new System.ComponentModel.Int64Converter(); 
            }
            else if (type == typeof(UInt32))
            {
                typeConverter = new System.ComponentModel.UInt32Converter(); 
            }
            else if (type == typeof(UInt16)) 
            { 
                typeConverter = new System.ComponentModel.UInt16Converter();
            } 
            else if (type == typeof(UInt64))
            {
                typeConverter = new System.ComponentModel.UInt64Converter();
            } 
            else if (type == typeof(Boolean))
            { 
                typeConverter = new System.ComponentModel.BooleanConverter(); 
            }
            else if (type == typeof(Double)) 
            {
                typeConverter = new System.ComponentModel.DoubleConverter();
            }
            else if (type == typeof(Single)) 
            {
                typeConverter = new System.ComponentModel.SingleConverter(); 
            } 
            else if (type == typeof(Byte))
            { 
                typeConverter = new System.ComponentModel.ByteConverter();
            }
            else if (type == typeof(SByte))
            { 
                typeConverter = new System.ComponentModel.SByteConverter();
            } 
            else if (type == typeof(Char)) 
            {
                typeConverter = new System.ComponentModel.CharConverter(); 
            }
            else if (type == typeof(Decimal))
            {
                typeConverter = new System.ComponentModel.DecimalConverter(); 
            }
            else if (type == typeof(TimeSpan)) 
            { 
                typeConverter = new System.ComponentModel.TimeSpanConverter();
            } 
            else if (type == typeof(Guid))
            {
                typeConverter = new System.ComponentModel.GuidConverter();
            } 
            else if (type == typeof(String))
            { 
                typeConverter = new System.ComponentModel.StringConverter(); 
            }
            else if (type == typeof(CultureInfo)) 
            {
                typeConverter = new System.ComponentModel.CultureInfoConverter();
            }
#if !SYSTEM_XAML 
            else if (type == typeof(Type))
            { 
                typeConverter = new System.Windows.Markup.TypeTypeConverter(); 
            }
#else 
            else if (type == typeof(Type))
            {
                typeConverter = new System.Xaml.Replacements.TypeTypeConverter();
            } 
#endif
            else if (type == typeof(DateTime)) 
            { 
                typeConverter = new DateTimeConverter2();
            } 
            else if (ReflectionHelper.IsNullableType(type))
            {
                typeConverter = new System.ComponentModel.NullableConverter(type);
            } 

            return typeConverter; 
        } 
Esempio n. 17
0
        internal static TypeConverter GetCoreConverterFromCustomType(Type type) 
        {
            TypeConverter typeConverter = null;
            if (type.IsEnum)
            { 
                // Need to handle Enums types specially as they require a ctor that
                // takes the underlying type. 
                typeConverter = new System.ComponentModel.EnumConverter(type); 
            }
            else if (typeof(Int32).IsAssignableFrom(type)) 
            {
                typeConverter = new System.ComponentModel.Int32Converter();
            }
            else if (typeof(Int16).IsAssignableFrom(type)) 
            {
                typeConverter = new System.ComponentModel.Int16Converter(); 
            } 
            else if (typeof(Int64).IsAssignableFrom(type))
            { 
                typeConverter = new System.ComponentModel.Int64Converter();
            }
            else if (typeof(UInt32).IsAssignableFrom(type))
            { 
                typeConverter = new System.ComponentModel.UInt32Converter();
            } 
            else if (typeof(UInt16).IsAssignableFrom(type)) 
            {
                typeConverter = new System.ComponentModel.UInt16Converter(); 
            }
            else if (typeof(UInt64).IsAssignableFrom(type))
            {
                typeConverter = new System.ComponentModel.UInt64Converter(); 
            }
            else if (typeof(Boolean).IsAssignableFrom(type)) 
            { 
                typeConverter = new System.ComponentModel.BooleanConverter();
            } 
            else if (typeof(Double).IsAssignableFrom(type))
            {
                typeConverter = new System.ComponentModel.DoubleConverter();
            } 
            else if (typeof(Single).IsAssignableFrom(type))
            { 
                typeConverter = new System.ComponentModel.SingleConverter(); 
            }
            else if (typeof(Byte).IsAssignableFrom(type)) 
            {
                typeConverter = new System.ComponentModel.ByteConverter();
            }
            else if (typeof(SByte).IsAssignableFrom(type)) 
            {
                typeConverter = new System.ComponentModel.SByteConverter(); 
            } 
            else if (typeof(Char).IsAssignableFrom(type))
            { 
                typeConverter = new System.ComponentModel.CharConverter();
            }
            else if (typeof(Decimal).IsAssignableFrom(type))
            { 
                typeConverter = new System.ComponentModel.DecimalConverter();
            } 
            else if (typeof(TimeSpan).IsAssignableFrom(type)) 
            {
                typeConverter = new System.ComponentModel.TimeSpanConverter(); 
            }
            else if (typeof(Guid).IsAssignableFrom(type))
            {
                typeConverter = new System.ComponentModel.GuidConverter(); 
            }
            else if (typeof(String).IsAssignableFrom(type)) 
            { 
                typeConverter = new System.ComponentModel.StringConverter();
            } 
            else if (typeof(CultureInfo).IsAssignableFrom(type))
            {
                typeConverter = new System.ComponentModel.CultureInfoConverter();
            } 
#if !SYSTEM_XAML
            else if (typeof(Type).IsAssignableFrom(type)) 
            { 
                typeConverter = new System.Windows.Markup.TypeTypeConverter();
            } 
#else
            else if (type == typeof(Type))
            {
                typeConverter = new System.Xaml.Replacements.TypeTypeConverter(); 
            }
#endif 
            else if (typeof(DateTime).IsAssignableFrom(type)) 
            {
                typeConverter = new DateTimeConverter2(); 
            }

            return typeConverter;
        } 
Esempio n. 18
0
        internal static TypeConverter GetCoreConverterFromCustomType(Type type)
        {
            TypeConverter typeConverter = null;

            if (type.IsEnum)
            {
                // Need to handle Enums types specially as they require a ctor that
                // takes the underlying type.
                typeConverter = new System.ComponentModel.EnumConverter(type);
            }
            else if (typeof(Int32).IsAssignableFrom(type))
            {
                typeConverter = new System.ComponentModel.Int32Converter();
            }
            else if (typeof(Int16).IsAssignableFrom(type))
            {
                typeConverter = new System.ComponentModel.Int16Converter();
            }
            else if (typeof(Int64).IsAssignableFrom(type))
            {
                typeConverter = new System.ComponentModel.Int64Converter();
            }
            else if (typeof(UInt32).IsAssignableFrom(type))
            {
                typeConverter = new System.ComponentModel.UInt32Converter();
            }
            else if (typeof(UInt16).IsAssignableFrom(type))
            {
                typeConverter = new System.ComponentModel.UInt16Converter();
            }
            else if (typeof(UInt64).IsAssignableFrom(type))
            {
                typeConverter = new System.ComponentModel.UInt64Converter();
            }
            else if (typeof(Boolean).IsAssignableFrom(type))
            {
                typeConverter = new System.ComponentModel.BooleanConverter();
            }
            else if (typeof(Double).IsAssignableFrom(type))
            {
                typeConverter = new System.ComponentModel.DoubleConverter();
            }
            else if (typeof(Single).IsAssignableFrom(type))
            {
                typeConverter = new System.ComponentModel.SingleConverter();
            }
            else if (typeof(Byte).IsAssignableFrom(type))
            {
                typeConverter = new System.ComponentModel.ByteConverter();
            }
            else if (typeof(SByte).IsAssignableFrom(type))
            {
                typeConverter = new System.ComponentModel.SByteConverter();
            }
            else if (typeof(Char).IsAssignableFrom(type))
            {
                typeConverter = new System.ComponentModel.CharConverter();
            }
            else if (typeof(Decimal).IsAssignableFrom(type))
            {
                typeConverter = new System.ComponentModel.DecimalConverter();
            }
            else if (typeof(TimeSpan).IsAssignableFrom(type))
            {
                typeConverter = new System.ComponentModel.TimeSpanConverter();
            }
            else if (typeof(Guid).IsAssignableFrom(type))
            {
                typeConverter = new System.ComponentModel.GuidConverter();
            }
            else if (typeof(String).IsAssignableFrom(type))
            {
                typeConverter = new System.ComponentModel.StringConverter();
            }
            else if (typeof(CultureInfo).IsAssignableFrom(type))
            {
                typeConverter = new System.ComponentModel.CultureInfoConverter();
            }
#if !SYSTEM_XAML
            else if (typeof(Type).IsAssignableFrom(type))
            {
                typeConverter = new System.Windows.Markup.TypeTypeConverter();
            }
#else
            else if (type == typeof(Type))
            {
                typeConverter = new System.Xaml.Replacements.TypeTypeConverter();
            }
#endif
            else if (typeof(DateTime).IsAssignableFrom(type))
            {
                typeConverter = new DateTimeConverter2();
            }
            else if (typeof(Uri).IsAssignableFrom(type))
            {
                typeConverter = new System.Xaml.Replacements.TypeUriConverter();
            }

            return(typeConverter);
        }
Esempio n. 19
0
        public override SdataTransactionResult Update(PayloadBase payload, List<SyncFeedEntryLink> links)
        {
            SdataTransactionResult tmpTransactionResult;
            salesOrdertype salesorder = null;

            #region check input values
            if (!(payload is SalesOrderPayload))
            {
                tmpTransactionResult = new SdataTransactionResult();
                tmpTransactionResult.HttpMethod = "PUT";
                tmpTransactionResult.ResourceKind = _resourceKind;
                tmpTransactionResult.HttpStatus = System.Net.HttpStatusCode.BadRequest;
                tmpTransactionResult.HttpMessage = ("salesorder payload missing");
                return tmpTransactionResult;
            }
            salesorder = (payload as SalesOrderPayload).SalesOrdertype;

            if (salesorder == null)
            {
                tmpTransactionResult = new SdataTransactionResult();
                tmpTransactionResult.HttpMethod = "PUT";
                tmpTransactionResult.ResourceKind = _resourceKind;
                tmpTransactionResult.HttpStatus = System.Net.HttpStatusCode.BadRequest;
                tmpTransactionResult.HttpMessage = ("salesorder payload missing");
                return tmpTransactionResult;

            }
            foreach (SyncFeedEntryLink link in links)
            {
                if (link.LinkRel != RelEnum.related.ToString())
                    continue;
                string localID = string.Empty;
                if (link.Href.StartsWith(_context.DatasetLink, StringComparison.InvariantCultureIgnoreCase))
                    if (link.Href.LastIndexOf("('") < link.Href.LastIndexOf("')"))
                        localID = link.Href.Substring(link.Href.LastIndexOf("('") + 2,
                            link.Href.LastIndexOf("')") - link.Href.LastIndexOf("('") - 2);

                SupportedResourceKinds reskind = ResourceKindHelpers.GetResourceKind(link.PayloadPath);

                if (localID == string.Empty)
                    localID = GetLocalId(link.Uuid, reskind);

                payload.ForeignIds.Add(link.PayloadPath, localID);
            }

            if (payload == null)
                return null;

            string customerID;

            if (!payload.ForeignIds.TryGetValue("tradingAccount", out customerID))
            {
                tmpTransactionResult = new SdataTransactionResult();
                tmpTransactionResult.HttpMethod = "PUT";
                tmpTransactionResult.ResourceKind = _resourceKind;
                tmpTransactionResult.HttpStatus = System.Net.HttpStatusCode.BadRequest;
                tmpTransactionResult.HttpMessage = ("Trading Acount Id missing");
                return tmpTransactionResult;
            }

            if (!customerID.StartsWith(Sage.Integration.Northwind.Application.API.Constants.CustomerIdPrefix))
            {
                tmpTransactionResult = new SdataTransactionResult();
                tmpTransactionResult.HttpMethod = "PUT";
                tmpTransactionResult.ResourceKind = _resourceKind;
                tmpTransactionResult.HttpStatus = System.Net.HttpStatusCode.BadRequest;
                tmpTransactionResult.HttpMessage = ("Salesorder submission is only supported by customers");
                return tmpTransactionResult;
            }
            #endregion

            DataSets.OrderTableAdapters.OrdersTableAdapter tableAdapter = new OrdersTableAdapter();
            DataSets.OrderTableAdapters.Order_DetailsTableAdapter detailsTableAdapter=new Order_DetailsTableAdapter();

            DataSets.Order order = new DataSets.Order();

            int id;
            if (!(Int32.TryParse(payload.LocalID, out id)))
                id = 0;
            int recordCount;

            using (OleDbConnection connection = new OleDbConnection(_context.Config.ConnectionString))
            {
                tableAdapter.Connection = connection;
                recordCount = tableAdapter.FillBy(order.Orders, id);
                if (recordCount == 0)
                    return null;

                detailsTableAdapter.Connection = connection;
                detailsTableAdapter.FillBy(order.Order_Details, id);

            }

            DataSets.Order.OrdersRow row = (DataSets.Order.OrdersRow)order.Orders[0];

            #region fill dataset from document
            try
            {
                if (!salesorder.dateSpecified)
                    row.SetOrderDateNull();
                else
                    row.OrderDate = salesorder.date;

                if (!salesorder.dueDateSpecified)
                    row.SetRequiredDateNull();
                else
                    row.RequiredDate = (DateTime)salesorder.dueDate;

                //if (orderDoc.shippedvia.IsNull)
                //    newOrder.SetShipViaNull();
                //else
                //    newOrder.ShipVia = (int)orderDoc.shippedvia.Value;

                if (salesorder.postalAddresses == null || salesorder.postalAddresses.Length == 0)
                {
                    row.SetShipAddressNull();
                    row.SetShipCityNull();
                    row.SetShipCountryNull();
                    row.SetShipPostalCodeNull();
                }
                else
                {
                    postalAddresstype postadress = salesorder.postalAddresses[0];
                    row.ShipAddress = postadress.address1;
                    row.ShipCity = postadress.townCity;
                    row.ShipPostalCode = postadress.zipPostCode;
                    row.ShipCountry = postadress.country;

                }

                if (!salesorder.carrierTotalPriceSpecified)
                    row.Freight = (decimal)0;
                else
                    row.Freight = (decimal)salesorder.carrierTotalPrice;

                //row.CreateUser = _context.Config.CrmUser;
                row.ModifyUser = _context.Config.CrmUser;
                //row.CreateID = _context.Config.SequenceNumber;
                row.ModifyID = _context.Config.SequenceNumber;

                Dictionary<Guid, SyncFeedEntryLink> itemLinks = new Dictionary<Guid, SyncFeedEntryLink>();
                GuidConverter converter = new GuidConverter();
                 Guid itemUuid;

                foreach (SyncFeedEntryLink link in links)
                {
                    SupportedResourceKinds resKind = ResourceKindHelpers.GetResourceKind(link.PayloadPath);
                    if (resKind != SupportedResourceKinds.salesOrderLines)
                        continue;
                    try
                    {

                        itemUuid = (Guid)converter.ConvertFromString(link.Uuid);
                        if (!Guid.Empty.Equals(itemUuid))
                            itemLinks.Add(itemUuid, link);
                    }
                    catch (Exception)
                    {
                    }
                }
                List<DataSets.Order.Order_DetailsRow> rowsToDelete = new List<DataSets.Order.Order_DetailsRow>();

                //foreach (DataSets.Order.Order_DetailsRow detailsRow in rowsToDelete)
                //{
                //    detailsRow.Delete();
                //}

                foreach (DataSets.Order.Order_DetailsRow detailsRow in order.Order_Details)
                {
                    string itemId = detailsRow.OrderID.ToString() + "-" + detailsRow.ProductID.ToString();
                    itemUuid = GetUuid(itemId, "", SupportedResourceKinds.salesOrderLines);
                    SyncFeedEntryLink itemlink;
                    if (itemLinks.TryGetValue(itemUuid, out itemlink))
                    {
                        string lineNumberstring = itemlink.PayloadPath.Substring(itemlink.PayloadPath.IndexOf("[") + 1, itemlink.PayloadPath.IndexOf("]") - itemlink.PayloadPath.IndexOf("[") - 1);
                        int lineNumber;
                        if (Int32.TryParse(lineNumberstring, out lineNumber))
                        {
                            if (lineNumber < salesorder.salesOrderLines.Length)
                            {
                                salesOrderLinetype soLine = salesorder.salesOrderLines[lineNumber];
                                detailsRow.ModifyUser = _context.Config.CrmUser;
                                detailsRow.ModifyID = _context.Config.SequenceNumber;
                                if (soLine.quantitySpecified)
                                    detailsRow.Quantity = Convert.ToInt16(soLine.quantity);
                                else
                                    detailsRow.Quantity = 0;

                                if (soLine.initialPriceSpecified)
                                    detailsRow.UnitPrice = (Decimal)soLine.initialPrice;
                                else
                                    detailsRow.UnitPrice = 0;

                                if ((!soLine.discountTotalSpecified) || (detailsRow.Quantity == 0) || (detailsRow.UnitPrice == 0))
                                {
                                    detailsRow.Discount = (float)0;
                                }
                                else
                                {
                                    // discountPC = discountsum / qunatity * listprice
                                    //detailRow.Discount = Convert.ToSingle((decimal)lineItemDoc.discountsum.Value / ((decimal)detailRow.Quantity * detailRow.UnitPrice));
                                    float discount = Convert.ToSingle((decimal)soLine.discountTotal / (detailsRow.UnitPrice));
                                    if (discount > 1)
                                        discount = 0;
                                    detailsRow.Discount = discount;
                                }

                            }
                        }
                        itemLinks.Remove(itemUuid);
                    }
                    else
                    {
                        //delete item
                        rowsToDelete.Add(detailsRow);
                    }

                }

                foreach (SyncFeedEntryLink itemlink in itemLinks.Values)
                {
                    {
                        try
                        {
                            int productID;
                            string productIdString;
                            string productIdPayload = String.Format("{0}/{1}", itemlink.PayloadPath, "commodity");

                            if (payload.ForeignIds.TryGetValue(productIdPayload, out productIdString))
                            {
                                try
                                {
                                    productID = Convert.ToInt32(productIdString);
                                }
                                catch (Exception)
                                {
                                    continue;
                                }
                            }
                            else
                                continue;

                            string lineNumberstring = itemlink.PayloadPath.Substring(itemlink.PayloadPath.IndexOf("[") + 1, itemlink.PayloadPath.IndexOf("]") - itemlink.PayloadPath.IndexOf("[") - 1);
                            int lineNumber;
                            if (Int32.TryParse(lineNumberstring, out lineNumber))
                            {
                                if (lineNumber < salesorder.salesOrderLines.Length)
                                {
                                    salesOrderLinetype soLine = salesorder.salesOrderLines[lineNumber];

                                    DataSets.Order.Order_DetailsRow detailRow = order.Order_Details.NewOrder_DetailsRow();
                                    soLine.applicationID = payload.LocalID + "-" + productID.ToString();
                                    detailRow.OrderID = Convert.ToInt32(payload.LocalID);
                                    detailRow.ProductID = productID;
                                    if (soLine.quantitySpecified)
                                        detailRow.Quantity = Convert.ToInt16(soLine.quantity);
                                    else
                                        detailRow.Quantity = 0;

                                    if (soLine.initialPriceSpecified)
                                        detailRow.UnitPrice = (Decimal)soLine.initialPrice;
                                    else
                                        detailRow.UnitPrice = 0;

                                    if ((!soLine.discountTotalSpecified) || (detailRow.Quantity == 0) || (detailRow.UnitPrice == 0))
                                    {
                                        detailRow.Discount = (float)0;
                                    }
                                    else
                                    {
                                        // discountPC = discountsum / qunatity * listprice
                                        //detailRow.Discount = Convert.ToSingle((decimal)lineItemDoc.discountsum.Value / ((decimal)detailRow.Quantity * detailRow.UnitPrice));
                                        float discount = Convert.ToSingle((decimal)soLine.discountTotal / (detailRow.UnitPrice));
                                        if (discount > 1)
                                            discount = 0;
                                        detailRow.Discount = discount;
                                    }

                                    detailRow.CreateUser = _context.Config.CrmUser;
                                    detailRow.ModifyUser = _context.Config.CrmUser;
                                    detailRow.CreateID = _context.Config.SequenceNumber;
                                    detailRow.ModifyID = _context.Config.SequenceNumber;
                                    order.Order_Details.AddOrder_DetailsRow(detailRow);
                                }
                            }
                        }
                        // this error occours in case of invalid data types
                        catch (Exception e)
                        {

                            tmpTransactionResult = new SdataTransactionResult();
                            tmpTransactionResult.HttpMethod = "POST";
                            tmpTransactionResult.ResourceKind = _resourceKind;
                            tmpTransactionResult.HttpStatus = System.Net.HttpStatusCode.BadRequest;
                            tmpTransactionResult.HttpMessage = e.Message;
                            return tmpTransactionResult;

                        }

                    }

                }

                using (OleDbConnection connection = new OleDbConnection(_context.Config.ConnectionString))
                {
                    OleDbTransaction transaction = null;
                    try
                    {
                        connection.Open();
                        transaction = connection.BeginTransaction();

                        tableAdapter.Connection = connection;
                        detailsTableAdapter.Connection = connection;

                        tableAdapter.SetTransaction(transaction);
                        detailsTableAdapter.SetTransaction(transaction);

                        foreach (DataSets.Order.Order_DetailsRow detailsRow in rowsToDelete)
                        {
                            detailsTableAdapter.Delete(detailsRow.OrderID,
                                detailsRow.ProductID,
                                detailsRow.UnitPrice, detailsRow.Quantity,
                                detailsRow.Discount, detailsRow.CreateID, detailsRow.CreateUser, detailsRow.ModifyID, detailsRow.ModifyUser);
                        }

                        tableAdapter.Update(order.Orders);
                        detailsTableAdapter.Update(order.Order_Details);

                        transaction.Commit();

                        tmpTransactionResult = new SdataTransactionResult();
                        tmpTransactionResult.HttpMethod = "PUT";
                        tmpTransactionResult.ResourceKind = _resourceKind;
                        tmpTransactionResult.HttpStatus = System.Net.HttpStatusCode.OK;
                        tmpTransactionResult.LocalId = payload.LocalID;
                        return tmpTransactionResult;

                    }
                    catch (Exception transactionException)
                    {
                        if (transaction != null)
                            transaction.Rollback();
                        throw;
                    }

                }
            }
            catch (Exception e)
            {
                tmpTransactionResult = new SdataTransactionResult();
                tmpTransactionResult.HttpMethod = "PUT";
                tmpTransactionResult.ResourceKind = _resourceKind;
                tmpTransactionResult.HttpStatus = System.Net.HttpStatusCode.BadRequest;
                tmpTransactionResult.HttpMessage = e.ToString();
                return tmpTransactionResult;
            }

            #endregion
        }
Esempio n. 20
0
 // Initialize known object types
 internal static TypeConverter CreateKnownTypeConverter(Int16 converterId)
 { 
     TypeConverter o = null;
     switch (converterId) 
     { 
         case -42: o = new System.Windows.Media.Converters.BoolIListConverter(); break;
         case -46: o = new System.ComponentModel.BooleanConverter(); break; 
         case -53: o = new System.Windows.Media.BrushConverter(); break;
         case -61: o = new System.ComponentModel.ByteConverter(); break;
         case -70: o = new System.ComponentModel.CharConverter(); break;
         case -71: o = new System.Windows.Media.Converters.CharIListConverter(); break; 
         case -87: o = new System.Windows.Media.ColorConverter(); break;
         case -94: o = new System.Windows.Input.CommandConverter(); break; 
         case -96: o = new System.Windows.Markup.ComponentResourceKeyConverter(); break; 
         case -111: o = new System.Windows.CornerRadiusConverter(); break;
         case -114: o = new System.ComponentModel.CultureInfoConverter(); break; 
         case -115: o = new System.Windows.CultureInfoIetfLanguageTagConverter(); break;
         case -117: o = new System.Windows.Input.CursorConverter(); break;
         case -124: o = new System.ComponentModel.DateTimeConverter(); break;
         case -125: o = new System.Windows.Markup.DateTimeConverter2(); break; 
         case -130: o = new System.ComponentModel.DecimalConverter(); break;
         case -137: o = new System.Windows.Markup.DependencyPropertyConverter(); break; 
         case -138: o = new System.Windows.DialogResultConverter(); break; 
         case -174: o = new System.Windows.Media.DoubleCollectionConverter(); break;
         case -175: o = new System.ComponentModel.DoubleConverter(); break; 
         case -176: o = new System.Windows.Media.Converters.DoubleIListConverter(); break;
         case -188: o = new System.Windows.DurationConverter(); break;
         case -190: o = new System.Windows.DynamicResourceExtensionConverter(); break;
         case -201: o = new System.Windows.ExpressionConverter(); break; 
         case -204: o = new System.Windows.FigureLengthConverter(); break;
         case -215: o = new System.Windows.Media.FontFamilyConverter(); break; 
         case -216: o = new System.Windows.FontSizeConverter(); break; 
         case -218: o = new System.Windows.FontStretchConverter(); break;
         case -220: o = new System.Windows.FontStyleConverter(); break; 
         case -222: o = new System.Windows.FontWeightConverter(); break;
         case -240: o = new System.Windows.Media.GeometryConverter(); break;
         case -256: o = new System.Windows.GridLengthConverter(); break;
         case -267: o = new System.ComponentModel.GuidConverter(); break; 
         case -286: o = new System.Windows.Media.ImageSourceConverter(); break;
         case -299: o = new System.Windows.Input.InputScopeConverter(); break; 
         case -301: o = new System.Windows.Input.InputScopeNameConverter(); break; 
         case -306: o = new System.ComponentModel.Int16Converter(); break;
         case -314: o = new System.Windows.Media.Int32CollectionConverter(); break; 
         case -315: o = new System.ComponentModel.Int32Converter(); break;
         case -319: o = new System.Windows.Int32RectConverter(); break;
         case -324: o = new System.ComponentModel.Int64Converter(); break;
         case -338: o = new System.Windows.Input.KeyConverter(); break; 
         case -340: o = new System.Windows.Input.KeyGestureConverter(); break;
         case -342: o = new System.Windows.KeySplineConverter(); break; 
         case -344: o = new System.Windows.KeyTimeConverter(); break; 
         case -348: o = new System.Windows.LengthConverter(); break;
         case -387: o = new System.Windows.Media.Media3D.Matrix3DConverter(); break; 
         case -392: o = new System.Windows.Media.MatrixConverter(); break;
         case -410: o = new System.Windows.Input.ModifierKeysConverter(); break;
         case -411: o = new System.Windows.Input.MouseActionConverter(); break;
         case -415: o = new System.Windows.Input.MouseGestureConverter(); break; 
         case -423: o = new System.Windows.NullableBoolConverter(); break;
         case -445: o = new System.Windows.Media.PathFigureCollectionConverter(); break; 
         case -453: o = new System.Windows.Media.PixelFormatConverter(); break; 
         case -462: o = new System.Windows.Media.Media3D.Point3DCollectionConverter(); break;
         case -463: o = new System.Windows.Media.Media3D.Point3DConverter(); break; 
         case -467: o = new System.Windows.Media.Media3D.Point4DConverter(); break;
         case -473: o = new System.Windows.Media.PointCollectionConverter(); break;
         case -474: o = new System.Windows.PointConverter(); break;
         case -475: o = new System.Windows.Media.Converters.PointIListConverter(); break; 
         case -492: o = new System.Windows.PropertyPathConverter(); break;
         case -498: o = new System.Windows.Media.Media3D.QuaternionConverter(); break; 
         case -507: o = new System.Windows.Media.Media3D.Rect3DConverter(); break; 
         case -511: o = new System.Windows.RectConverter(); break;
         case -521: o = new System.Windows.Media.Animation.RepeatBehaviorConverter(); break; 
         case -538: o = new System.Windows.Markup.RoutedEventConverter(); break;
         case -545: o = new System.ComponentModel.SByteConverter(); break;
         case -563: o = new System.ComponentModel.SingleConverter(); break;
         case -568: o = new System.Windows.Media.Media3D.Size3DConverter(); break; 
         case -572: o = new System.Windows.SizeConverter(); break;
         case -615: o = new System.ComponentModel.StringConverter(); break; 
         case -619: o = new System.Windows.StrokeCollectionConverter(); break; 
         case -633: o = new System.Windows.TemplateBindingExpressionConverter(); break;
         case -635: o = new System.Windows.TemplateBindingExtensionConverter(); break; 
         case -637: o = new System.Windows.Markup.TemplateKeyConverter(); break;
         case -645: o = new System.Windows.TextDecorationCollectionConverter(); break;
         case -655: o = new System.Windows.ThicknessConverter(); break;
         case -664: o = new System.ComponentModel.TimeSpanConverter(); break; 
         case -681: o = new System.Windows.Media.TransformConverter(); break;
         case -692: o = new System.Windows.Markup.TypeTypeConverter(); break; 
         case -696: o = new System.ComponentModel.UInt16Converter(); break; 
         case -698: o = new System.ComponentModel.UInt32Converter(); break;
         case -700: o = new System.ComponentModel.UInt64Converter(); break; 
         case -701: o = new System.Windows.Media.Converters.UShortIListConverter(); break;
         case -705: o = new System.UriTypeConverter(); break;
         case -714: o = new System.Windows.Media.Media3D.Vector3DCollectionConverter(); break;
         case -715: o = new System.Windows.Media.Media3D.Vector3DConverter(); break; 
         case -722: o = new System.Windows.Media.VectorCollectionConverter(); break;
         case -723: o = new System.Windows.VectorConverter(); break; 
         case -757: o = new System.Windows.Markup.XmlLanguageConverter(); break; 
     }
     return o; 
 }
Esempio n. 21
0
		private /*static*/ object readValue(XmlReader xmlReader, Type type, IFormatterConverter converter)
		{
			System.Diagnostics.Debug.Assert(null != xmlReader, "The 'xmlReader' argument cannot be null.");
			System.Diagnostics.Debug.Assert(null != type, "The 'type' argument cannot be null.");
			System.Diagnostics.Debug.Assert(this.isSimpleType(type), "The Type type is not a simple type.");
			System.Diagnostics.Debug.Assert(null != converter, "The 'converter' argument cannot be null.");

			object value = null; // Return value			
			string valueRepresentation = xmlReader.ReadString();
			if (type.IsPrimitive || typeof(System.String) == type) {
				value = converter.Convert(valueRepresentation, type);
			}
			else if (type.IsEnum) {
				value = Enum.Parse(type, valueRepresentation);
			}
			else if (typeof(System.Guid) == type) {
				value = new GuidConverter().ConvertFromInvariantString(valueRepresentation);
			}

			// When the value is the empty string the xml element is empty and there is not an xml end element.
			// Read the following element.
			if (xmlReader.IsEmptyElement)
				xmlReader.ReadStartElement();

			return value;
		}