Esempio n. 1
0
        internal static object InternalGetInstance(SupportedTypes type, int index, ReferenceDepthContext context)
        {
            if (!context.IncreamentCounter())
            {
                return null;
            }

            if (type == SupportedTypes.Person)
            {
                return new Person(index, context);
            }
            else if (type == SupportedTypes.Employee)
            {
                return new Employee(index, context);
            }
            else if (type == SupportedTypes.Address)
            {
                return new Address(index, context);
            }
            else if (type == SupportedTypes.WorkItem)
            {
                return new WorkItem() { EmployeeID = index, IsCompleted = false, NumberOfHours = 100, ID = 25 };
            }

            context.DecrementCounter();

            throw new ArgumentException(String.Format("Cannot initialize an instance for {0} type.", type.ToString()));

        }
Esempio n. 2
0
 /// <summary>
 /// Helper method to convert the supported output format to the enum .NET expects
 /// </summary>
 /// <param name="type">Output format to be converted</param>
 public static ImageFormat ToImageFormat(SupportedTypes type)
 {
     switch (type) {
             case SupportedTypes.Bitmap: return ImageFormat.Bmp;
             case SupportedTypes.Gif: return ImageFormat.Gif;
             case SupportedTypes.Jpeg: return ImageFormat.Jpeg;
             case SupportedTypes.Png: return ImageFormat.Png;
             default: throw new ArgumentException(string.Format("{0} is not a supported output format.", type.ToString()) );
         }
 }
Esempio n. 3
0
 /// <summary>
 /// Helper method to get the correct file extension for the supported type 
 /// (ensuring the correct application opens the poster once downloaded to the Client's browser).
 /// </summary>
 /// <param name="type">Output format to get the extension of</param>
 /// <returns></returns>
 public static string ToFileExtension(SupportedTypes type)
 {
     switch (type) {
             case SupportedTypes.Bitmap: return "bmp";
             case SupportedTypes.Gif: return "gif";
             case SupportedTypes.Jpeg: return "jpg";
             case SupportedTypes.Png: return "png";
             default: throw new ArgumentException(string.Format("{0} is not a supported output format.", type.ToString()) );
         }
 }
Esempio n. 4
0
        internal static object InternalGetInstance(SupportedTypes type, int index, ReferenceDepthContext context)
        {
            if (!context.IncreamentCounter())
            {
                return(null);
            }

            if (type == SupportedTypes.Person)
            {
                return(new Person(index, context));
            }
            else if (type == SupportedTypes.Employee)
            {
                return(new Employee(index, context));
            }
            else if (type == SupportedTypes.Address)
            {
                return(new Address(index, context));
            }
            else if (type == SupportedTypes.WorkItem)
            {
                return(new WorkItem()
                {
                    EmployeeID = index, IsCompleted = false, NumberOfHours = 100, ID = 25
                });
            }

            context.DecrementCounter();

            throw new ArgumentException(String.Format("Cannot initialize an instance for {0} type.", type.ToString()));
        }
Esempio n. 5
0
        }                 // ToContentType

        /// <summary>
        /// Helper method to get the correct file extension for the supported type
        /// (ensuring the correct application opens the poster once downloaded to the Client's browser).
        /// </summary>
        /// <param name="type">Output format to get the extension of</param>
        /// <returns></returns>
        public static string ToFileExtension(SupportedTypes type)
        {
            switch (type)
            {
            case SupportedTypes.Bitmap: return("bmp");

            case SupportedTypes.Gif: return("gif");

            case SupportedTypes.Jpeg: return("jpg");

            case SupportedTypes.Png: return("png");

            default: throw new ArgumentException(string.Format("{0} is not a supported output format.", type.ToString()));
            }
        }         // ToContentType
Esempio n. 6
0
        }                 // FromString

        /// <summary>
        /// Helper method to convert the supported output format to the enum .NET expects
        /// </summary>
        /// <param name="type">Output format to be converted</param>
        public static ImageFormat ToImageFormat(SupportedTypes type)
        {
            switch (type)
            {
            case SupportedTypes.Bitmap: return(ImageFormat.Bmp);

            case SupportedTypes.Gif: return(ImageFormat.Gif);

            case SupportedTypes.Jpeg: return(ImageFormat.Jpeg);

            case SupportedTypes.Png: return(ImageFormat.Png);

            default: throw new ArgumentException(string.Format("{0} is not a supported output format.", type.ToString()));
            }
        }                 // ToImageFormat